You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Joel Quiles edited this page Dec 8, 2023
·
1 revision
Article Status: Currently handled by Docker Setup.
Use the below info as reference, as it may be out of date.
We currently use postgres for airflow, and elasticsearch for the Dojo API.
Intro to the api-postgres database:
In the docker-compose.yaml file the api-postgres service needs to be defined. The environment values "POSTGRES_DB", "POSTGRES_PASSWORD", and "POSTGRES_USER" are all needed in creating the database on docker-compose up.
In the api service the env variable "DATASET_DB_URL" needs to be set to connect to that created database which if the database name, user or password changes this url needs to change to match that.
Creating engine and connecting
There is a db.py file which creates the database engine object which should only be created once in the project and imported to each file as needed.
To connect to the database with a session use the SQLModel Session function and pass in the engine object.
Creating tables
To create the tables I created an endpoint on dojo that uses the SQLModel library to create the database tables. Making sure the import of the models is before the import of the engine object to make sure all tables are created.