feat: configuration FastAPI et moteur SQLAlchemy async

This commit is contained in:
2026-05-24 04:49:41 +02:00
parent b46c8351df
commit ee00848fdc
2 changed files with 36 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession
from sqlalchemy.orm import DeclarativeBase
from app.core.config import settings
engine = create_async_engine(settings.database_url, pool_pre_ping=True)
AsyncSessionLocal = async_sessionmaker(engine, expire_on_commit=False)
class Base(DeclarativeBase):
pass
async def get_session() -> AsyncSession:
async with AsyncSessionLocal() as session:
yield session