Spaces:
Running
Running
| from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession | |
| from app.core.config import settings | |
| engine = create_async_engine( | |
| settings.DATABASE_URL, | |
| echo=False, | |
| future=True, | |
| ) | |
| SessionLocal = async_sessionmaker( | |
| autocommit=False, | |
| autoflush=False, | |
| bind=engine, | |
| class_=AsyncSession, | |
| expire_on_commit=False, | |
| ) | |
| async def get_db(): | |
| async with SessionLocal() as session: | |
| yield session | |