Exemplo n.º 1
0
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
Exemplo n.º 2
0
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())
Exemplo n.º 3
0
async def get_db() -> Generator:
    async with async_session() as session:
        yield session
Exemplo n.º 4
0
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