HolbertonBnB supports the following classes:
The above classes are handled byh one of either two abstracted storage engines, depending on the call - FileStorage or DBStorage.
The defualt 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.
Chigozirim Igweamaka - <iChigozirim>