kenken999's picture
fda
0f43f8a
raw
history blame
407 Bytes
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from models import Base
SQLALCHEMY_DATABASE_URL = "sqlite:///database.db"
engine = create_engine(SQLALCHEMY_DATABASE_URL)
Base.metadata.create_all(engine)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()