mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
refactor(structure): move to 7project dir
This commit is contained in:
14
7project/backend/app/services/db.py
Normal file
14
7project/backend/app/services/db.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from typing import AsyncGenerator
|
||||
from fastapi import Depends
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from fastapi_users.db import SQLAlchemyUserDatabase
|
||||
|
||||
from ..core.db import async_session_maker
|
||||
from ..models.user import User
|
||||
|
||||
async def get_async_session() -> AsyncGenerator[AsyncSession, None]:
|
||||
async with async_session_maker() as session:
|
||||
yield session
|
||||
|
||||
async def get_user_db(session: AsyncSession = Depends(get_async_session)):
|
||||
yield SQLAlchemyUserDatabase(session, User)
|
||||
Reference in New Issue
Block a user