2023-09-11 23:48:38 +01:00
2023-08-05 01:12:16 +01:00
2023-08-10 13:18:13 +01:00
2023-09-11 23:48:38 +01:00
2023-09-02 00:48:55 +01:00
2023-09-11 23:48:38 +01:00
2023-07-11 12:30:39 +01:00
2023-09-11 23:48:38 +01:00
2023-07-04 11:16:29 +01:00
2023-09-11 23:48:38 +01:00
2023-03-05 12:20:02 +00:00
2023-07-03 17:42:53 +01:00
2023-05-25 17:03:40 +01:00
2023-07-04 02:29:38 +01:00
2023-07-04 02:29:38 +01:00
2023-07-04 02:29:38 +01:00
2023-03-08 17:39:23 +00:00
2023-06-30 12:25:07 +01:00
2023-06-30 12:25:07 +01:00
2023-03-08 17:39:41 +00:00
2023-07-13 12:19:32 +01:00
2023-09-01 01:23:25 +01:00
2023-09-01 02:38:57 +01:00
2023-09-11 23:48:38 +01:00
2023-09-11 23:48:38 +01:00
2023-08-09 16:16:45 +01:00
2023-08-25 09:56:09 +01:00
2023-01-11 14:54:42 +00:00
2023-09-01 16:01:42 +01:00
2023-07-04 02:29:38 +01:00
2023-07-11 12:30:39 +01:00
2023-02-24 15:06:19 +00:00
2023-08-10 13:18:13 +01:00
2023-03-29 15:06:22 +01:00
2023-04-21 13:33:24 +01:00
2023-07-03 17:42:53 +01:00

Go bindings to SQLite using Wazero

Go Reference Go Report Go Coverage

Go module github.com/ncruces/go-sqlite3 wraps a WASM build of SQLite, and uses wazero to provide cgo-free SQLite bindings.

Caveats

This module replaces the SQLite OS Interface (aka VFS) with a pure Go implementation. This has benefits, but also comes with some drawbacks.

Write-Ahead Logging

Because WASM does not support shared memory, WAL support is limited.

To work around this limitation, SQLite is patched to always use EXCLUSIVE locking mode for WAL databases.

Because connection pooling is incompatible with EXCLUSIVE locking mode, to use the database/sql driver with WAL databases you should disable connection pooling by calling db.SetMaxOpenConns(1).

POSIX Advisory Locks

POSIX advisory locks, which SQLite uses, are broken by design.

On Linux, macOS and illumos, this module uses OFD locks to synchronize access to database files. OFD locks are fully compatible with process-associated POSIX advisory locks.

On BSD Unixes, this module uses BSD locks. BSD locks may not be compatible with process-associated POSIX advisory locks (they are on FreeBSD).

TL;DR

In all platforms for which this package builds, it is safe to use it to access databases concurrently from multiple goroutines.

Additionally, on Windows, Linux, macOS, illumos and FreeBSD, it is also safe to use it to access databases concurrently with other implementations of SQLite.

On other BSDs, where this might be unsafe, this test should fail.

Testing

The pure Go VFS is tested by running SQLite's mptest on Linux, macOS and Windows; BSD code paths are tested on macOS using the sqlite3_bsd build tag. Performance is tested by running speedtest1.

Roadmap

  • advanced SQLite features
    • custom functions
    • nested transactions
    • incremental BLOB I/O
    • online backup
    • session extension
  • custom VFSes

Alternatives

Description
No description provided
Readme MIT 49 MiB
Languages
Go 89.9%
C 5.2%
WebAssembly 3.5%
Shell 1.4%