mirror of
https://github.com/sstent/FitTrack_ReportGenerator.git
synced 2026-03-16 01:46:00 +00:00
21 lines
452 B
Python
21 lines
452 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
import os
|
|
|
|
DATABASE_URL = os.getenv(
|
|
"DATABASE_URL", "sqlite:///./test.db"
|
|
)
|
|
|
|
engine = create_engine(DATABASE_URL)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
Base = declarative_base()
|
|
|
|
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|