Coverage for app / core / database.py: 75%
8 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-21 22:41 +0300
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-21 22:41 +0300
1from typing import AsyncGenerator
3from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
5from app.core.config import settings
7engine = create_async_engine(settings.db_url)
9AsyncSessionLocal = async_sessionmaker(
10 bind=engine,
11 class_=AsyncSession,
12 autoflush=False,
13 autocommit=False,
14 expire_on_commit=False,
15)
18async def get_db() -> AsyncGenerator[AsyncSession, None]:
19 async with AsyncSessionLocal() as session:
20 yield session