async def init() -> None: try: # Try to create session to check if DB is awake async with async_session() as db: await db.execute("SELECT 1") except Exception as e: logger.error(e) raise e
def main(): from src.db.session import async_session db = async_session() config_seeding = ConfigSeeding() #asyncio.get_event_loop().run_until_complete(config_seeding.create_first_user(db)) #asyncio.get_event_loop().run_until_complete(config_seeding.sync_base_customization(db)) asyncio.get_event_loop().run_until_complete( config_seeding.dump_default_config(db)) asyncio.get_event_loop().run_until_complete(db.close())
async def get_db() -> Generator: async with async_session() as session: yield session
async def startup_event(): print("App is starting...") async with async_session() as db: table_index = await crud.layer.table_index(db) app.state.table_catalog = table_index