stress_at_work_analysis/setup.py

30 lines
597 B
Python
Raw Permalink Normal View History

2020-12-24 14:29:47 +01:00
import os
2020-12-24 16:06:23 +01:00
import sqlalchemy.engine.url
from dotenv import load_dotenv
2020-12-24 16:46:55 +01:00
from sqlalchemy import create_engine
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
db_uri = sqlalchemy.engine.url.URL(
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()