AlxBnB supports the following classes:
- BaseModel
- User
- State
- City
- Amenity
- Place
- Review
The above classes are handled by one of either two abstracted storage engines, depending on the call - FileStorage or DBStorage.
The default mode.
In FileStorage
mode, every time the backend is initialized, HolbertonBnB
instantiates an instance of FileStorage
called storage
. The storage
object is loaded/re-loaded from any class instances stored in the JSON file
file.json
. As class instances are created, updated, or deleted, the
storage
object is used to register corresponding changes in the file.json
.
Run by setting the environmental variables HBNB_TYPE_STORAGE=db
.
In DBStorage
mode, every time the backend is initialized, HolbertonBnB
instantiates an instance of DBStorage
called storage
. The storage
object
is loaded/re-loaded from the MySQL database specified in the environmental variable
HBNB_MYSQL_DB
, using the user HBNB_MYSQL_USER
, password HBNB_MYSQL_PWD
, and
host HBNB_MYSQL_HOST
. As class instances are created, updated, or deleted, the
storage
object is used to register changes in the corresponding MySQL database.
Connection and querying is achieved using SQLAlchemy.
Note that the databases specified for DBStorage
to connect to must already be
defined on the MySQL server. This repository includes scripts
setup_mysql_dev.sql and setup_mysql_test.sql
to set up hbnb_dev_db
and hbnb_test_db
databases in a MySQL server,
respectively.
The console is a command line interpreter that permits management of the backend
of HolbertonBnB. It can be used to handle and manipulate all classes utilized by
the application (achieved by calls on the storage
object defined above).