This proyect is the implementation of an storeg engine, and how to store all the information about users in a json file, control by a console, as the name mentioned this proyect create a console in interactive and non-interactive mode, and it used to create and implement a lot of command to recreate a storeg engine
<class 'BaseModel'> -> to_dict() -> <class 'dict'> -> JSON dump -> <class 'str'> -> FILE -> <class 'str'> -> JSON load -> <class 'dict'> -> <class 'BaseModel'>
This is the process of Serialization and deserialization to a json file
AirBnB$ ./console.pyΒ """interactive mode"""
(hbnb) help
Documented commands (type help < topic >):
EOF all create destroy help quit show update
(hbnb)
(hbnb) quit
AirBnB$ echo "help" | ./console.pyΒ """non-interactive mode""" (hbnb)
Documented commands (type help < topic >):
This is the command's list:
- helpΒ - Shows information about the console or its commands - Usage: help or help create
- EOFΒ - Exits the console
- quitΒ - Exits the console
- createΒ - Creates an instance - Usage: create Class
- showΒ - Prints the string representation of an instance - Usage: show Class id
- destroyΒ - Deletes an intance - Usage: destroy Class id
- allΒ - Prints all string representation of all instance - Usage: all or all Class
- updateΒ - Updates an instance - Usage: update Class id attribute value
Create:
(hbnb) create BaseModel
929fab0f-efb4-4eb7-9cfa-27c57cd167df
(hbnb) create User
5aa4eec2-ce66-4415-ba41-28c3207a68b6
(hbnb) create Place
63514b83-af33-4038-9c66-256fefc35165
destroy:
(hbnb) create Place
9fd1f506-9cc7-4ba8-9b2f-d6bda9bbcddb
(hbnb) destroy Place 9fd1f506-9cc7-4ba8-9b2f-d6bda9bbcddb
(hbnb) show Place 9fd1f506-9cc7-4ba8-9b3f-d6bda9bbcddb
** no instance found **
all:
(hbnb) create BaseModel
bf876ce4-ecc9-4185-8d22-88c23cbe4f28
(hbnb) create BaseModel
61691f4f-f58c-4b58-8618-14472c984061
(hbnb) create User
81fc9995-016a-4f47-85ef-62bb73ce5e1c
(hbnb) all
["[BaseModel] (bf876ce4-ecc9-4185-8d22-88c23cbe4f28) {'id': 'bf876ce4-ecc9-4185-8d22-88c23cbe4f28', 'created_at': datetime.datetime(2022, 7, 6, 15, 49, 15, 483376), 'updated_at': datetime.datetime(2022, 7, 6, 15, 49, 15, 483395)}", "[BaseModel] (61691f4f-f58c-4b58-8618-14472c984061) {'id': '61691f4f-f58c-4b58-8618-14472c984061', 'created_at': datetime.datetime(2022, 7, 6, 15, 49, 31, 624055), 'updated_at': datetime.datetime(2022, 7, 6, 15, 49, 31, 624070)}", "[User] (81fc9995-016a-4f47-85ef-62bb73ce5e1c) {'id': '81fc9995-016a-4f47-85ef-62bb73ce5e1c', 'created_at': datetime.datetime(2022, 7, 6, 15, 49, 36, 876947), 'updated_at': datetime.datetime(2022, 7, 6, 15, 49, 36, 877007)}"]