Commit 37a5d2c0 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

Update db.py

parent 86464609
...@@ -53,8 +53,19 @@ if "sqlite" in SQLALCHEMY_DATABASE_URL: ...@@ -53,8 +53,19 @@ if "sqlite" in SQLALCHEMY_DATABASE_URL:
) )
else: else:
engine = create_engine(SQLALCHEMY_DATABASE_URL, pool_pre_ping=True) engine = create_engine(SQLALCHEMY_DATABASE_URL, pool_pre_ping=True)
SessionLocal = sessionmaker( SessionLocal = sessionmaker(
autocommit=False, autoflush=False, bind=engine, expire_on_commit=False autocommit=False, autoflush=False, bind=engine, expire_on_commit=False
) )
Base = declarative_base() Base = declarative_base()
Session = scoped_session(SessionLocal) Session = scoped_session(SessionLocal)
# Dependency
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment