kenken999's picture
test
1f074d8
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()