wasm_sqlite

View Source

SQLite 3.54.1, compiled from the upstream amalgamation, running inside a WebAssembly guest on erlang_wasm, with no NIF. SQL, prepared statements, transactions, FTS5, JSON and R-tree, in rollback-journal mode. The guest is prebuilt in priv/wasm_sqlite.wasm; priv/BUILD-INFO says what it was built from.

{ok, Db} = wasm_sqlite:open(#{storage => {wasm_storage_file, "data.sqlite"}}),
ok = wasm_sqlite:execute(Db, <<"CREATE TABLE items (id INTEGER PRIMARY KEY, value TEXT)">>, []),
{ok, []} = wasm_sqlite:query(Db, <<"SELECT * FROM items">>, []).

It is much slower than a NIF SQLite. Before you depend on it, read the SQLite guide for the build options and the journal mode, what an error means and the project's status.