Files
fastcon-backend/app/core/database.py

11 lines
435 B
Python
Raw Normal View History

2026-02-22 00:05:04 +08:00
from sqlmodel.ext.asyncio.session import AsyncSession
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
2026-02-21 14:56:19 +08:00
from app.core.config import settings
2026-02-22 00:05:04 +08:00
engine = create_async_engine(settings.database_url, echo=True, future=True)
2026-02-21 14:56:19 +08:00
2026-02-22 00:05:04 +08:00
AsyncSessionLocal = async_sessionmaker(bind=engine, class_=AsyncSession, expire_on_commit=False)
async def get_session():
async with AsyncSessionLocal() as session:
2026-02-21 14:56:19 +08:00
yield session