You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
597 B

import os
import sqlalchemy.engine.url
from dotenv import load_dotenv
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
load_dotenv()
testing: bool = False
db_password = os.getenv("DB_PASSWORD")
db_uri = sqlalchemy.engine.url.URL(
drivername="postgresql+psycopg2",
username="staw_db",
password=db_password,
host="212.235.208.113",
port=5432,
database="staw",
)
if testing:
db_engine = create_engine("sqlite:///:memory:", echo=True)
else:
db_engine = create_engine(db_uri)
Session = sessionmaker(bind=db_engine)
session = Session()