Skip to content

Commit 2b2b703

Browse files
authored
Update depends.py
1 parent dfe4d57 commit 2b2b703

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/api/depends.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
async def get_db() -> Database:
1616
async with AsyncSession(bind=engine, expire_on_commit=False) as session:
17-
return Database(session)
17+
try:
18+
yield Database(session)
19+
finally:
20+
await session.close()
1821

1922

2023
async def get_current_user(token: str = Depends(oauth2_scheme), db: Database = Depends(get_db)):

0 commit comments

Comments
 (0)