cysqlite - a new sqlite driver
18 points by coleifer
18 points by coleifer
I got this working as a compiled WebAssembly wheel that works in Pyodide in a browser - here's a demo page that runs the tests: https://simonw.github.io/research/cysqlite-wasm-wheel/demo.html
The wheel is here: https://simonw.github.io/research/cysqlite-wasm-wheel/cysqlite-0.1.4-cp311-cp311-emscripten_3_1_46_wasm32.whl
You can load that in the Pyodide REPL and try it out here: https://tools.simonwillison.net/pyodide-repl
import micropip
await micropip.install("https://simonw.github.io/research/cysqlite-wasm-wheel/cysqlite-0.1.4-cp311-cp311-emscripten_3_1_46_wasm32.whl")
import cysqlite
cysqlite.connect(":memory:").execute("select sqlite_version()").fetchone()
This is really exciting! I'm a longtime fan of pysqlite3 and I've always wanted custom
Table-valued functions, looks like this gives me exactly that.
Thanks, Simon I hope others like yourself find it useful. It's been a lot of fun to work on.
Uh, the in_transaction being True after .commit() is cursed in autocommit=True, I didn't know about. Seems like using the connection context manager is safer.
I know, I'm not sure how the cpython team decided on that, but seems like it will drop data on the floor for the unwary, since a subsequent close() on the connection implies a rollback (it is not explicitly rolled-back, but that is effectively what happens).
You should upload free-threaded cp314t wheels! See https://py-free-threading.github.io for more info but I’m also happy to help.