Categorygithub.com/ncruces/go-sqlite3
modulepackage
0.18.0
Repository: https://github.com/ncruces/go-sqlite3.git
Documentation: pkg.go.dev

# README

Go bindings to SQLite using Wazero

Go Reference Go Report Go Coverage

Go module github.com/ncruces/go-sqlite3 is a cgo-free SQLite wrapper.
It provides a database/sql compatible driver, as well as direct access to most of the C SQLite API.

It wraps a Wasm build of SQLite, and uses wazero as the runtime.
Go, wazero and x/sys are the only runtime dependencies 1.

Packages

Extensions

Advanced features

Caveats

This module replaces the SQLite OS Interface (aka VFS) with a pure Go implementation, which has advantages and disadvantages.

Read more about the Go VFS design here.

Testing

This project aims for high test coverage. It also benefits greatly from SQLite's and wazero's thorough testing.

Every commit is tested on Linux (amd64/arm64/386/riscv64/s390x), macOS (amd64/arm64), Windows (amd64), FreeBSD (amd64), OpenBSD (amd64), NetBSD (amd64), illumos (amd64), and Solaris (amd64).

The Go VFS is tested by running SQLite's mptest.

Performance

Perfomance of the database/sql driver is competitive with alternatives.

The Wasm and VFS layers are also tested by running SQLite's speedtest1.

Alternatives

Footnotes

  1. anything else you find in go.mod is either a test dependency, or needed by one of the extensions.

# Packages

Package driver provides a database/sql driver for SQLite.
Package embed embeds SQLite into your application.
No description provided by the author
Package gormlite provides a GORM driver for SQLite.
No description provided by the author
No description provided by the author
Package vfs wraps the C SQLite VFS API.

# Functions

AutoExtension causes the entryPoint function to be invoked for each new database connection that is created.
CreateModule registers a new virtual table module name.
Initialize decodes and compiles the SQLite Wasm binary.
JSON returns a value that can be used as an argument to [database/sql.DB.Exec], [database/sql.Row.Scan] and similar methods to store value as JSON, or decode JSON into value.
Open calls [OpenFlags] with [OPEN_READWRITE], [OPEN_CREATE], [OPEN_URI] and [OPEN_NOFOLLOW].
OpenFlags opens an SQLite database file as specified by the filename argument.
Pointer returns a pointer to a value that can be used as an argument to [database/sql.DB.Exec] and similar methods.
Quote escapes and quotes a value making it safe to embed in SQL text.
QuoteIdentifier escapes and quotes an identifier making it safe to embed in SQL text.

# Constants

Callback routine requested an abort */.
No description provided by the author
Authorization denied */.
Database Name Table Name */.
Table Name NULL */.
Filename NULL */.
Index Name Table Name */.
Table Name NULL */.
Index Name Table Name */.
Table Name NULL */.
Trigger Name Table Name */.
View Name NULL */.
Trigger Name Table Name */.
View Name NULL */.
Table Name Module Name */.
Table Name NULL */.
Abort the SQL statement with an error */.
Database Name NULL */.
Index Name Table Name */.
Table Name NULL */.
Index Name Table Name */.
Table Name NULL */.
Trigger Name Table Name */.
View Name NULL */.
Trigger Name Table Name */.
View Name NULL */.
Table Name Module Name */.
NULL Function Name */.
Don't allow access, but don't generate an error */.
Table Name NULL */.
No description provided by the author
Pragma Name 1st arg or NULL */.
Table Name Column Name */.
NULL NULL */.
Index Name NULL */.
Operation Savepoint Name */.
NULL NULL */.
Operation NULL */.
Table Name Column Name */.
No description provided by the author
No description provided by the author
The database file is locked */.
No description provided by the author
No description provided by the author
No description provided by the author
Unable to open the database file */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
CANTOPEN_DIRTYWAL ExtendedErrorCode = xErrorCode(CANTOPEN) | (5 << 8) /* Not Used */.
Wait for writers, then checkpoint */.
Do as much as possible w/o blocking */.
Like FULL but wait for readers */.
Like RESTART but also truncate WAL */.
Abort due to constraint violation */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
The database disk image is malformed */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
DBCONFIG_MAINDBNAME DBConfig = 1000 DBCONFIG_LOOKASIDE DBConfig = 1001.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Internal use only */.
Generic error */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Not used */.
Insertion failed because database is full */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Internal logic error in SQLite */.
Operation terminated by sqlite3_interrupt() */.
Some kind of disk I/O error occurred */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
A table in the database is locked */.
No description provided by the author
No description provided by the author
Data type mismatch */.
Library used incorrectly */.
Uses OS features not supported on host */.
A malloc() failed */.
File opened that is not a database file */.
Unknown opcode in sqlite3_file_control() */.
Notifications from sqlite3_log() */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Ok for sqlite3_open_v2() */.
Extended result codes */.
Ok for sqlite3_open_v2() */.
Ok for sqlite3_open_v2() */.
Ok for sqlite3_open_v2() */.
Ok for sqlite3_open_v2() */.
Ok for sqlite3_open_v2() */.
Ok for sqlite3_open_v2() */.
Ok for sqlite3_open_v2() */.
Ok for sqlite3_open_v2() */.
Ok for sqlite3_open_v2() */.
Access permission denied */.
No description provided by the author
No description provided by the author
No description provided by the author
Database lock protocol error */.
2nd parameter to sqlite3_bind out of range */.
Attempt to write a readonly database */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
The database schema changed */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Text formats.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
Auto.
time.RFC3339Nano.
Numeric formats.
TimeFormats recognized by SQLite to encode/decode time values.
TimeFormats recognized by SQLite to encode/decode time values.
not an SQLite format.
not an SQLite format.
not an SQLite format.
String or BLOB exceeds size limit */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Warnings from sqlite3_log() */.
No description provided by the author

# Variables

Wasm binary to load.
Path to load the binary from.
Configure SQLite Wasm.

# Structs

Backup is an handle to an ongoing online backup operation.
Blob is an handle to an open BLOB.
Conn is a database connection handle.
Context is the context in which an SQL function executes.
Error wraps an SQLite Error Code.
An IndexConstraint describes virtual table indexing constraint information.
An IndexConstraintUsage describes how virtual table indexing constraints will be used.
An IndexInfo describes virtual table indexing information.
An IndexOrderBy describes virtual table indexing order by information.
Savepoint is a marker within a transaction that allows for partial rollback.
Stmt is a prepared statement object.
Txn is an in-progress database transaction.
Value is any value that can be stored in a database table.

# Interfaces

AggregateFunction is the interface an aggregate function should implement.
DriverConn is implemented by the SQLite [database/sql] driver connection.
A VTab describes a particular instance of the virtual table.
A VTabChecker allows a virtual table to report errors to the PRAGMA integrity_check and PRAGMA quick_check commands.
A VTabCursor describes cursors that point into the virtual table and are used to loop through the virtual table.
A VTabDestroyer allows a virtual table to drop persistent state.
A VTabOverloader allows a virtual table to overload SQL functions.
A VTabRenamer allows a virtual table to be renamed.
A VTabSavepointer allows a virtual table to implement nested transactions.
A VTabShadowTabler allows a virtual table to protect the content of shadow tables from being corrupted by hostile SQL.
A VTabTxn allows a virtual table to implement transactions with two-phase commit.
A VTabUpdater allows a virtual table to be updated.
WindowFunction is the interface an aggregate window function should implement.

# Type aliases

AuthorizerActionCode are the integer action codes that the authorizer callback may be passed.
AuthorizerReturnCode are the integer codes that the authorizer callback may return.
CheckpointMode are all the checkpoint mode values.
Datatype is a fundamental datatype of SQLite.
DBConfig are the available database connection configuration options.
DBStatus are the available "verbs" that can be passed to the [Conn.Status] method.
ErrorCode is a result code that [Error.Code] might return.
ExtendedErrorCode is a result code that [Error.ExtendedCode] might return.
FcntlOpcode are the available opcodes for [Conn.FileControl].
FunctionFlag is a flag that can be passed to [Conn.CreateFunction] and [Conn.CreateWindowFunction].
IndexConstraintOp is a virtual table constraint operator code.
IndexScanFlag is a virtual table scan flag.
LimitCategory are the available run-time limit categories.
OpenFlag is a flag for the [OpenFlags] function.
PrepareFlag is a flag that can be passed to [Conn.PrepareFlags].
ScalarFunction is the type of a scalar SQL function.
StmtStatus name counter values associated with the [Stmt.Status] method.
TimeFormat specifies how to encode/decode time values.
TraceEvent identify classes of events that can be monitored with [Conn.Trace].
TxnState are the allowed return values from [Conn.TxnState].
VTabConfigOption is a virtual table configuration option.
VTabConflictMode is a virtual table conflict resolution mode.
VTabConstructor is a virtual table constructor function.
ZeroBlob represents a zero-filled, length n BLOB that can be used as an argument to [database/sql.DB.Exec] and similar methods.