Update app/db.py
Browse files
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()
|