Module realm_api.db
Database functionality
Functions
async def get_session()-
Expand source code
async def get_session(): """Get an `AsyncSession` object.""" async with AsyncSession(async_engine) as session: yield sessionGet an
AsyncSessionobject. async def init_db()-
Expand source code
async def init_db(): """Initialize the database. Used in the FastAPI application lifespan.""" from . import models # noqa: F401 logger.info("Initializing database") async with async_engine.begin() as conn: await conn.run_sync(SQLModel.metadata.create_all)Initialize the database. Used in the FastAPI application lifespan.