You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
448 B
17 lines
448 B
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession |
|
from sqlalchemy.orm import DeclarativeBase |
|
|
|
from app.config import settings |
|
|
|
engine = create_async_engine(settings.database_url, echo=True) |
|
|
|
AsyncSessionLocal = async_sessionmaker(engine, expire_on_commit=False) |
|
|
|
|
|
class Base(DeclarativeBase): |
|
pass |
|
|
|
|
|
async def get_db() -> AsyncSession: |
|
async with AsyncSessionLocal() as session: |
|
yield session
|
|
|