city_retrofit/persistence
2022-11-08 21:24:57 -05:00
..
models Added repo methods to fetch cities and buildings 2022-11-08 21:03:48 -05:00
repositories Added repo methods to fetch cities and buildings 2022-11-08 21:03:48 -05:00
__init__.py Included repository for persisting building 2022-11-03 15:29:09 -04:00
Base.py Included repository for persisting building 2022-11-03 15:29:09 -04:00
db_config.py Included repository for persisting building 2022-11-03 15:29:09 -04:00
README.md Added a readme file 2022-11-08 21:24:57 -05:00

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