SQLite 3.40.0 with WASM Support
sqlite.org
sqlite.org
The other day I learned that it's built into Observable notebooks now - so if you have a SQLite database file that's hosted anywhere online with open CORS headers you can load and query that directly from a notebook.
This notebook here uses that trick: https://observablehq.com/@simonw/mastodon-users-and-statuses... - I wrote more about how that all works here: https://simonwillison.net/2022/Nov/20/tracking-mastodon/
SQLite compiled to WASM is also bundled with the Python Pyodide WebAssembly system, which is how my https://lite.datasette.io/ Datasette Lite application works: https://simonwillison.net/2022/May/4/datasette-lite/
Essentially, the OPFS enables true ACID compliance, without it you have to "stop the world" and serialise the SQLite db to a string for saving in IndexedDB.
The trifactor of the Origin-Private FileSystem, WASM and SQLite is the missing link to make so many progressive web apps possible.
WASM SQLite persistance options: https://sqlite.org/wasm/doc/trunk/persistence.md
FWIW, that's exactly our sentiment within the sqlite team. People have been using sqlite with browser-side JS since at least as far back as 2012, but availability of OPFS was the catalyst which piqued our interests in jumping on the WASM bandwagon.
For those who work with it regularly; have you noticed any dramatic changes in query speeds in the past few years/versions? I imagine that most improvements to the code have been around new features but there may be some big speed gains in 'bread and butter operations' like queries or updates, but I am not aware of anything specific.
Definitely hope it gets merged into main.
We (sqlite team) are currently working on patches to get it building properly with wasi-sdk. When built as-is with wasi it's essentially non-functional due to missing POSIX I/O emulation bits. i think we can expect to see that build land by the 3.41 release.
Right now I can run SQLite on my iPad under a-Shell pretty well, but there seems to be a bug in the REPL (not sure where) and memory usage skyrockets.
Would love to see this working in a CLI environment.