-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add postgresql db config (with sqlalchemy) (#20)
* Install psycopg2 & sqlalchemy dependencies * Setup DB * Connect to DB on startup * Update documentation * Remove .env.example file, simplify setup
- Loading branch information
Showing
8 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.engine import URL | ||
from sqlalchemy.orm import sessionmaker | ||
|
||
from app.config import settings | ||
|
||
|
||
url = URL.create( | ||
drivername="postgresql", | ||
database=settings.postgres_db_name, | ||
username=settings.postgres_user, | ||
password=settings.postgres_password, | ||
host=settings.postgres_host, | ||
port=settings.postgres_port, | ||
) | ||
|
||
engine = create_engine(url) | ||
|
||
session = sessionmaker(autocommit=False, autoflush=False, bind=engine) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
fastapi==0.103.1 | ||
jinja2==3.1.2 | ||
openfoodfacts==0.1.10 | ||
peewee==3.17.0 | ||
psycopg2-binary==2.9.9 | ||
pydantic-settings==2.0.3 | ||
requests==2.31.0 | ||
sentry-sdk[fastapi]==1.31.0 | ||
sqlalchemy==2.0.23 | ||
uvicorn==0.23.2 |