Releases: h0rn3t/fastapi-async-sqlalchemy
Releases · h0rn3t/fastapi-async-sqlalchemy
WIP multi sessions
WIP multi sessions
@router.get("/concurrent-queries")
async def parallel_select():
async with db(multi_sessions=True):
async def execute_query(query):
return await db.session.execute(text(query))
tasks = [
asyncio.create_task(execute_query("SELECT 1")),
asyncio.create_task(execute_query("SELECT 2")),
asyncio.create_task(execute_query("SELECT 3")),
asyncio.create_task(execute_query("SELECT 4")),
asyncio.create_task(execute_query("SELECT 5")),
asyncio.create_task(execute_query("SELECT 6")),
]
await asyncio.gather(*tasks)