krz/hutch-notify

Notification server for Hutch.

clone: git clone https://gitbay.org/krz/hutch-notify.git

main: app/db.py · raw

 1from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine, AsyncSession
 2from sqlalchemy.orm import DeclarativeBase
 3from app.config import settings
 4
 5
 6class Base(DeclarativeBase):
 7    pass
 8
 9
10engine = create_async_engine(settings.database_url, future=True)
11SessionLocal = async_sessionmaker(engine, expire_on_commit=False, class_=AsyncSession)
12
13
14async def get_db() -> AsyncSession:
15    async with SessionLocal() as session:
16        yield session