feat: add settings and async db engine

This commit is contained in:
Indiana
2026-07-20 15:01:25 +00:00
parent 1747c355e0
commit 9e69c622c9
4 changed files with 48 additions and 0 deletions

16
backend/app/db.py Normal file
View File

@@ -0,0 +1,16 @@
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from sqlalchemy.orm import DeclarativeBase
from app.config import settings
engine = create_async_engine(settings.database_url, echo=False)
async_session_maker = async_sessionmaker(engine, expire_on_commit=False)
class Base(DeclarativeBase):
pass
async def get_db() -> AsyncSession:
async with async_session_maker() as session:
yield session