12 lines
311 B
Python
12 lines
311 B
Python
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
|
|
|
|
from config import cfg
|
|
|
|
engine = create_async_engine(cfg.db_url, echo=True)
|
|
async_session = async_sessionmaker(bind=engine, expire_on_commit=False)
|
|
|
|
|
|
async def get_db():
|
|
async with async_session() as session:
|
|
yield session
|