Example of AIOSQL
import asyncio
import aiosql
import aiosqlite
queries = aiosql.from_path("./greetings.sql", "aiosqlite")
async def main():
# Parallel queries!!!
async with aiosqlite.connect("greetings.db") as conn:
greetings, user = await asyncio.gather(
queries.get_all_greetings(conn),
queries.get_user_by_username(conn, username="willvaughn")
)
# greetings = [(1, "Hi"), (2, "Aloha"), (3, "Hola")]
# user = (1, "willvaughn", "William")
for _, greeting in greetings:
print(f"{greeting}, {user[2]}!")
# Hi, William!
# Aloha, William!
# Hola, William!
asyncio.run(main())