stress_at_work_analysis/setup.py

29 lines
558 B
Python
Raw Normal View History

2020-12-24 14:29:47 +01:00
import os
from dotenv import load_dotenv
2023-05-16 16:17:53 +02:00
from sqlalchemy import URL, create_engine
2020-12-24 16:46:55 +01:00
from sqlalchemy.orm import sessionmaker
2020-12-24 14:29:47 +01:00
load_dotenv()
testing: bool = False
2020-12-24 14:29:47 +01:00
db_password = os.getenv("DB_PASSWORD")
2020-12-24 16:06:23 +01:00
2023-05-16 16:17:53 +02:00
db_uri = URL.create(
drivername="postgresql+psycopg2",
2020-12-24 16:06:23 +01:00
username="staw_db",
password=db_password,
host="212.235.208.113",
port=5432,
database="staw",
2020-12-24 16:06:23 +01:00
)
2020-12-24 16:46:55 +01:00
if testing:
db_engine = create_engine("sqlite:///:memory:", echo=True)
else:
db_engine = create_engine(db_uri)
2020-12-24 16:46:55 +01:00
Session = sessionmaker(bind=db_engine)
session = Session()