Does anyone know of a way to use sqlite in python with Trio (asynchronously, of course)? I’m looking at something like this: https://github.com/omnilib/aiosqlite, but with support for Trio.
Hello,
We discussed this quickly in chat when you posted that question to Stack Overflow: python-trio/general - Gitter. There is no library with native Trio support, so here are your options:
Low-effort:
- Use the sqlite3 standard library with threads
- Not mentioned, but trio-asyncio could let you use aiosqlite from Trio
High-effort:
- Migrate aiosqlite to anyio, like Starlette, FastAPI and others did
- Create a native Trio library and handle cancellations like Datasette by using the sqlite3.Connection.set_progress_handler callback.
Hope that helps!