11 lines
435 B
Python
11 lines
435 B
Python
from sqlmodel.ext.asyncio.session import AsyncSession
|
|
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
|
|
from app.core.config import settings
|
|
|
|
engine = create_async_engine(settings.database_url, echo=True, future=True)
|
|
|
|
AsyncSessionLocal = async_sessionmaker(bind=engine, class_=AsyncSession, expire_on_commit=False)
|
|
|
|
async def get_session():
|
|
async with AsyncSessionLocal() as session:
|
|
yield session |