This commit is contained in:
Timothy J. Baek
2024-07-03 23:39:16 -07:00
parent 37a5d2c06b
commit 8fe2a7bb75
2 changed files with 9 additions and 2 deletions

View File

@@ -62,10 +62,16 @@ Base = declarative_base()
Session = scoped_session(SessionLocal)
from contextlib import contextmanager
# Dependency
def get_db():
def get_session():
db = SessionLocal()
try:
yield db
finally:
db.close()
get_db = contextmanager(get_session)