Repository navigation
The first release of sqlite3wasm, a database/sql driver for SQLite that needs no cgo. It is made for Go programs that run in a web browser.
SQLite 3.54.1 is built for WebAssembly with zig and embedded in the package. In a program built with GOOS=js GOARCH=wasm, the engine of the browser runs SQLite next to the Go program, so no WebAssembly runs inside other WebAssembly. On every other target, wazero runs the same module. That build is for go test ./... and is not meant for production. The package also builds with TinyGo.
- Every database is in memory.
:memory:belongs to one connection. Any other name is a memdb database that every connection of onesql.DBshares. Preload(name, data)gives a named database its starting content, so that a page can load a database file before a client such asusqlopens it.Conn.DeserializeandConn.Serializeload and save the bytes of a database.Conn.AutoCommitsays whether a connection is in a transaction.- An error from SQLite is a
*sqlite3wasm.Errorwith the primary and the extended result code, and hasErrVerboseforusql. - A context with a deadline stops a long statement, in a browser too.
- The data source name is
[sqlite3wasm:]name[?pragma=...].dburlv0.59.0 names this driver for the schemesqlite3wasmwhen it is built with-tags sqlite3wasm.
The tests run on wazero and in headless Chrome with chromedp. The only dependency of the package is wazero, and a browser build does not link it.