moriire commited on
Commit
7f960b1
1 Parent(s): 8d79926

Update app/db.py

Browse files
Files changed (1) hide show
  1. app/db.py +8 -0
app/db.py CHANGED
@@ -101,3 +101,11 @@ async def get_async_session() -> AsyncGenerator[AsyncSession, None]:
101
 
102
  async def get_user_db(session: AsyncSession = Depends(get_async_session)):
103
  yield SQLAlchemyUserDatabase(session, User)
 
 
 
 
 
 
 
 
 
101
 
102
  async def get_user_db(session: AsyncSession = Depends(get_async_session)):
103
  yield SQLAlchemyUserDatabase(session, User)
104
+
105
+
106
+ async def connect() -> None:
107
+ async with engine.begin() as conn:
108
+ await conn.run_sync(Base.metadata.create_all, checkfirst=True)
109
+ async def disconnect() -> None:
110
+ if engine:
111
+ await engine.dispose()