30 lines
1.2 KiB
Markdown
30 lines
1.2 KiB
Markdown
## Database Persistence ##
|
|
The persistence package includes classes to store different class objects in a Postgres database.
|
|
|
|
### models ###
|
|
This defines models for all class objects that we want to persist. It is used for Object Relation Mapping (ORM)
|
|
of the class objects to database table columns
|
|
|
|
### repositories ###
|
|
This defines repository classes that contain CRUD methods for database operations.
|
|
|
|
### config_db ##
|
|
This Python file is a configuration class that contains variables that map to configuration parameters in a .env file.
|
|
It also contains a method ``def conn_string()`` which returns the connection string to a Postgres database.
|
|
|
|
### Base ##
|
|
This class has a constructor that establishes a database connection and returns a reference for database-related CRUD operations.
|
|
|
|
### db_migration ###
|
|
This Python file is in the root of Hub and should be run to create all the required Postgres database tables
|
|
|
|
### Database Configuration Parameter ###
|
|
A .env file (or environment variables) with configuration parameters described below are needed to establish a database connection:
|
|
```
|
|
DB_NAME=postgres-database-name
|
|
DB_USER=postgres-database-user
|
|
DB_PASSWORD=postgres-database-password
|
|
DB_HOST=database-host
|
|
DB_PORT=database-port
|
|
```
|