from collections.abc import AsyncGenerator from loguru import logger from sqlalchemy import text from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine from wiregui.config import get_settings engine = create_async_engine(get_settings().database_url) async_session = async_sessionmaker(engine, expire_on_commit=False) async def get_session() -> AsyncGenerator[AsyncSession]: async with async_session() as session: yield session async def init_db() -> None: """Test database connectivity.""" async with engine.begin() as conn: await conn.execute(text("SELECT 1")) logger.info("Database connection OK")