from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from constants import async_connection_url

engine = create_async_engine(
    async_connection_url,
    pool_pre_ping=True,
    echo=True,
)

SessionLocal: async_sessionmaker[AsyncSession] = async_sessionmaker(
    bind=engine,
    expire_on_commit=False,
    class_=AsyncSession,
)

async def dispose_engine():
    await engine.dispose()
