2026-03-18 20:55:02 +00:00
|
|
|
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker
|
|
|
|
|
from sqlalchemy.orm import DeclarativeBase
|
|
|
|
|
|
2026-03-25 21:10:10 +00:00
|
|
|
from ...config import settings
|
2026-03-18 20:55:02 +00:00
|
|
|
|
|
|
|
|
engine = create_async_engine(settings.database_url)
|
|
|
|
|
AsyncSessionLocal = async_sessionmaker(engine, expire_on_commit=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def get_db():
|
|
|
|
|
async with AsyncSessionLocal() as session:
|
|
|
|
|
yield session
|