sqlite3

package module
v0.21.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 25 Imported by: 38

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 direct dependencies.

Getting started

Using the database/sql driver:


import "database/sql"
import _ "github.com/ncruces/go-sqlite3/driver"
import _ "github.com/ncruces/go-sqlite3/embed"

var version string
db, _ := sql.Open("sqlite3", "file:demo.db")
db.QueryRow(`SELECT sqlite_version()`).Scan(&version)
Packages
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/ppc64le/s390x), macOS (amd64/arm64), Windows (amd64), FreeBSD (amd64), OpenBSD (amd64), NetBSD (amd64), DragonFly BSD (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.

FAQ, issues, new features

For questions, please see Discussions.

Also, post there if you used this driver for something interesting ("Show and tell"), have an idea

The Issue tracker is for bugs we want fixed, and features we're working on, planning to work on, or asking for help with.

Alternatives

Documentation

Overview

Package sqlite3 wraps the C SQLite API.

Example
package main

import (
	"fmt"
	"log"

	"github.com/ncruces/go-sqlite3"
	_ "github.com/ncruces/go-sqlite3/embed"
)

const memory = ":memory:"

func main() {
	db, err := sqlite3.Open(memory)
	if err != nil {
		log.Fatal(err)
	}

	err = db.Exec(`CREATE TABLE users (id INT, name VARCHAR(10))`)
	if err != nil {
		log.Fatal(err)
	}

	err = db.Exec(`INSERT INTO users (id, name) VALUES (0, 'go'), (1, 'zig'), (2, 'whatever')`)
	if err != nil {
		log.Fatal(err)
	}

	stmt, _, err := db.Prepare(`SELECT id, name FROM users`)
	if err != nil {
		log.Fatal(err)
	}
	defer stmt.Close()

	for stmt.Step() {
		fmt.Println(stmt.ColumnInt(0), stmt.ColumnText(1))
	}
	if err := stmt.Err(); err != nil {
		log.Fatal(err)
	}

	err = stmt.Close()
	if err != nil {
		log.Fatal(err)
	}

	err = db.Close()
	if err != nil {
		log.Fatal(err)
	}
}
Output:

0 go
1 zig
2 whatever
Example (Json)
db, err := sqlite3.Open(":memory:")
if err != nil {
	log.Fatal(err)
}
defer db.Close()

err = db.Exec(`
		CREATE TABLE orders (
			cart_id INTEGER PRIMARY KEY,
			user_id INTEGER NOT NULL,
			cart    BLOB -- stored as JSONB
		) STRICT;
	`)
if err != nil {
	log.Fatal(err)
}

type CartItem struct {
	ItemID   string `json:"id"`
	Name     string `json:"name"`
	Quantity int    `json:"quantity,omitempty"`
	Price    int    `json:"price,omitempty"`
}

type Cart struct {
	Items []CartItem `json:"items"`
}

// convert to JSONB on insertion
stmt, _, err := db.Prepare(`INSERT INTO orders (user_id, cart) VALUES (?, jsonb(?))`)
if err != nil {
	log.Fatal(err)
}
defer stmt.Close()

if err := stmt.BindInt(1, 123); err != nil {
	log.Fatal(err)
}

if err := stmt.BindJSON(2, Cart{
	[]CartItem{
		{ItemID: "111", Name: "T-shirt", Quantity: 1, Price: 250},
		{ItemID: "222", Name: "Trousers", Quantity: 1, Price: 600},
	},
}); err != nil {
	log.Fatal(err)
}

if err := stmt.Exec(); err != nil {
	log.Fatal(err)
}

sl1, _, err := db.Prepare(`
		SELECT total(json_each.value -> 'price')
		FROM orders, json_each(cart -> 'items')
		WHERE cart_id = last_insert_rowid()
	`)
if err != nil {
	log.Fatal(err)
}
defer sl1.Close()

for sl1.Step() {
	fmt.Println("total:", sl1.ColumnInt(0))
}

if err := sl1.Err(); err != nil {
	log.Fatal(err)
}

sl2, _, err := db.Prepare(`
		SELECT json(cart) -- convert to JSON on retrieval
		FROM orders
		WHERE cart_id = last_insert_rowid()
	`)
if err != nil {
	log.Fatal(err)
}
defer sl2.Close()

for sl2.Step() {
	var cart Cart
	if err := sl2.ColumnJSON(0, &cart); err != nil {
		log.Fatal(err)
	}
	for _, item := range cart.Items {
		fmt.Printf("id: %s, name: %s, quantity: %d, price: %d\n",
			item.ItemID, item.Name, item.Quantity, item.Price)
	}
}

if err := sl2.Err(); err != nil {
	log.Fatal(err)
}
Output:

total: 850
id: 111, name: T-shirt, quantity: 1, price: 250
id: 222, name: Trousers, quantity: 1, price: 600

Index

Examples

Constants

View Source
const (
	TimeFormatDefault TimeFormat = "" // time.RFC3339Nano

	// Text formats
	TimeFormat1  TimeFormat = "2006-01-02"
	TimeFormat2  TimeFormat = "2006-01-02 15:04"
	TimeFormat3  TimeFormat = "2006-01-02 15:04:05"
	TimeFormat4  TimeFormat = "2006-01-02 15:04:05.000"
	TimeFormat5  TimeFormat = "2006-01-02T15:04"
	TimeFormat6  TimeFormat = "2006-01-02T15:04:05"
	TimeFormat7  TimeFormat = "2006-01-02T15:04:05.000"
	TimeFormat8  TimeFormat = "15:04"
	TimeFormat9  TimeFormat = "15:04:05"
	TimeFormat10 TimeFormat = "15:04:05.000"

	TimeFormat2TZ  = TimeFormat2 + "Z07:00"
	TimeFormat3TZ  = TimeFormat3 + "Z07:00"
	TimeFormat4TZ  = TimeFormat4 + "Z07:00"
	TimeFormat5TZ  = TimeFormat5 + "Z07:00"
	TimeFormat6TZ  = TimeFormat6 + "Z07:00"
	TimeFormat7TZ  = TimeFormat7 + "Z07:00"
	TimeFormat8TZ  = TimeFormat8 + "Z07:00"
	TimeFormat9TZ  = TimeFormat9 + "Z07:00"
	TimeFormat10TZ = TimeFormat10 + "Z07:00"

	// Numeric formats
	TimeFormatJulianDay TimeFormat = "julianday"
	TimeFormatUnix      TimeFormat = "unixepoch"
	TimeFormatUnixFrac  TimeFormat = "unixepoch_frac"
	TimeFormatUnixMilli TimeFormat = "unixepoch_milli" // not an SQLite format
	TimeFormatUnixMicro TimeFormat = "unixepoch_micro" // not an SQLite format
	TimeFormatUnixNano  TimeFormat = "unixepoch_nano"  // not an SQLite format

	// Auto
	TimeFormatAuto TimeFormat = "auto"
)

TimeFormats recognized by SQLite to encode/decode time values.

https://sqlite.org/lang_datefunc.html#time_values

Variables

View Source
var (
	Binary []byte // Wasm binary to load.
	Path   string // Path to load the binary from.

	RuntimeConfig wazero.RuntimeConfig
)

Configure SQLite Wasm.

Importing package embed initializes Binary with an appropriate build of SQLite:

import _ "github.com/ncruces/go-sqlite3/embed"

Functions

func AutoExtension added in v0.17.1

func AutoExtension(entryPoint func(*Conn) error)

AutoExtension causes the entryPoint function to be invoked for each new database connection that is created.

https://sqlite.org/c3ref/auto_extension.html

func CreateModule added in v0.10.3

func CreateModule[T VTab](db *Conn, name string, create, connect VTabConstructor[T]) error

CreateModule registers a new virtual table module name. If create is nil, the virtual table is eponymous.

https://sqlite.org/c3ref/create_module.html

Example
package main

import (
	"fmt"
	"log"

	"github.com/ncruces/go-sqlite3"
	_ "github.com/ncruces/go-sqlite3/embed"
)

func main() {
	db, err := sqlite3.Open(":memory:")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	err = sqlite3.CreateModule[seriesTable](db, "generate_series", nil,
		func(db *sqlite3.Conn, module, schema, table string, arg ...string) (seriesTable, error) {
			err := db.DeclareVTab(`CREATE TABLE x(value, start HIDDEN, stop HIDDEN, step HIDDEN)`)
			return seriesTable{}, err
		})
	if err != nil {
		log.Fatal(err)
	}

	stmt, _, err := db.Prepare(`SELECT rowid, value FROM generate_series(2, 10, 3)`)
	if err != nil {
		log.Fatal(err)
	}
	defer stmt.Close()

	for stmt.Step() {
		fmt.Println(stmt.ColumnInt(0), stmt.ColumnInt(1))
	}
	if err := stmt.Err(); err != nil {
		log.Fatal(err)
	}
}

type seriesTable struct{}

func (seriesTable) BestIndex(idx *sqlite3.IndexInfo) error {
	for i, cst := range idx.Constraint {
		switch cst.Column {
		case 1, 2, 3: // start, stop, step
			if cst.Op == sqlite3.INDEX_CONSTRAINT_EQ && cst.Usable {
				idx.ConstraintUsage[i] = sqlite3.IndexConstraintUsage{
					ArgvIndex: cst.Column,
					Omit:      true,
				}
			}
		}
	}
	idx.IdxNum = 1
	idx.IdxStr = "idx"
	return nil
}

func (seriesTable) Open() (sqlite3.VTabCursor, error) {
	return &seriesCursor{}, nil
}

type seriesCursor struct {
	start int64
	stop  int64
	step  int64
	value int64
}

func (cur *seriesCursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
	if idxNum != 1 || idxStr != "idx" {
		return nil
	}
	cur.start = 0
	cur.stop = 1000
	cur.step = 1
	if len(arg) > 0 {
		cur.start = arg[0].Int64()
	}
	if len(arg) > 1 {
		cur.stop = arg[1].Int64()
	}
	if len(arg) > 2 {
		cur.step = arg[2].Int64()
	}
	cur.value = cur.start
	return nil
}

func (cur *seriesCursor) Column(ctx sqlite3.Context, col int) error {
	switch col {
	case 0:
		ctx.ResultInt64(cur.value)
	case 1:
		ctx.ResultInt64(cur.start)
	case 2:
		ctx.ResultInt64(cur.stop)
	case 3:
		ctx.ResultInt64(cur.step)
	}
	return nil
}

func (cur *seriesCursor) Next() error {
	cur.value += cur.step
	return nil
}

func (cur *seriesCursor) EOF() bool {
	return cur.value > cur.stop
}

func (cur *seriesCursor) RowID() (int64, error) {
	return cur.value, nil
}
Output:

2 2
5 5
8 8

func Initialize added in v0.16.0

func Initialize() error

Initialize decodes and compiles the SQLite Wasm binary. This is called implicitly when the first connection is openned, but is potentially slow, so you may want to call it at a more convenient time.

func JSON added in v0.10.0

func JSON(value any) any

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. JSON should NOT be used with Stmt.BindJSON, Stmt.ColumnJSON, Value.JSON, or Context.ResultJSON.

func Pointer added in v0.10.1

func Pointer[T any](value T) any

Pointer returns a pointer to a value that can be used as an argument to database/sql.DB.Exec and similar methods. Pointer should NOT be used with Stmt.BindPointer, Value.Pointer, or Context.ResultPointer.

https://sqlite.org/bindptr.html

func Quote added in v0.10.1

func Quote(value any) string

Quote escapes and quotes a value making it safe to embed in SQL text. Strings with embedded NUL characters are truncated.

https://sqlite.org/lang_corefunc.html#quote

func QuoteIdentifier added in v0.10.1

func QuoteIdentifier(id string) string

QuoteIdentifier escapes and quotes an identifier making it safe to embed in SQL text. Strings with embedded NUL characters panic.

Types

type AggregateFunction added in v0.8.2

type AggregateFunction interface {
	// Step is invoked to add a row to the current window.
	// The function arguments, if any, corresponding to the row being added, are passed to Step.
	// Implementations must not retain arg.
	Step(ctx Context, arg ...Value)

	// Value is invoked to return the current (or final) value of the aggregate.
	Value(ctx Context)
}

AggregateFunction is the interface an aggregate function should implement.

https://sqlite.org/appfunc.html

type AuthorizerActionCode added in v0.12.1

type AuthorizerActionCode uint32

AuthorizerActionCode are the integer action codes that the authorizer callback may be passed.

https://sqlite.org/c3ref/c_alter_table.html

const (
	/***************************************************** 3rd ************ 4th ***********/
	AUTH_CREATE_INDEX        AuthorizerActionCode = 1  /* Index Name      Table Name      */
	AUTH_CREATE_TABLE        AuthorizerActionCode = 2  /* Table Name      NULL            */
	AUTH_CREATE_TEMP_INDEX   AuthorizerActionCode = 3  /* Index Name      Table Name      */
	AUTH_CREATE_TEMP_TABLE   AuthorizerActionCode = 4  /* Table Name      NULL            */
	AUTH_CREATE_TEMP_TRIGGER AuthorizerActionCode = 5  /* Trigger Name    Table Name      */
	AUTH_CREATE_TEMP_VIEW    AuthorizerActionCode = 6  /* View Name       NULL            */
	AUTH_CREATE_TRIGGER      AuthorizerActionCode = 7  /* Trigger Name    Table Name      */
	AUTH_CREATE_VIEW         AuthorizerActionCode = 8  /* View Name       NULL            */
	AUTH_DELETE              AuthorizerActionCode = 9  /* Table Name      NULL            */
	AUTH_DROP_INDEX          AuthorizerActionCode = 10 /* Index Name      Table Name      */
	AUTH_DROP_TABLE          AuthorizerActionCode = 11 /* Table Name      NULL            */
	AUTH_DROP_TEMP_INDEX     AuthorizerActionCode = 12 /* Index Name      Table Name      */
	AUTH_DROP_TEMP_TABLE     AuthorizerActionCode = 13 /* Table Name      NULL            */
	AUTH_DROP_TEMP_TRIGGER   AuthorizerActionCode = 14 /* Trigger Name    Table Name      */
	AUTH_DROP_TEMP_VIEW      AuthorizerActionCode = 15 /* View Name       NULL            */
	AUTH_DROP_TRIGGER        AuthorizerActionCode = 16 /* Trigger Name    Table Name      */
	AUTH_DROP_VIEW           AuthorizerActionCode = 17 /* View Name       NULL            */
	AUTH_INSERT              AuthorizerActionCode = 18 /* Table Name      NULL            */
	AUTH_PRAGMA              AuthorizerActionCode = 19 /* Pragma Name     1st arg or NULL */
	AUTH_READ                AuthorizerActionCode = 20 /* Table Name      Column Name     */
	AUTH_SELECT              AuthorizerActionCode = 21 /* NULL            NULL            */
	AUTH_TRANSACTION         AuthorizerActionCode = 22 /* Operation       NULL            */
	AUTH_UPDATE              AuthorizerActionCode = 23 /* Table Name      Column Name     */
	AUTH_ATTACH              AuthorizerActionCode = 24 /* Filename        NULL            */
	AUTH_DETACH              AuthorizerActionCode = 25 /* Database Name   NULL            */
	AUTH_ALTER_TABLE         AuthorizerActionCode = 26 /* Database Name   Table Name      */
	AUTH_REINDEX             AuthorizerActionCode = 27 /* Index Name      NULL            */
	AUTH_ANALYZE             AuthorizerActionCode = 28 /* Table Name      NULL            */
	AUTH_CREATE_VTABLE       AuthorizerActionCode = 29 /* Table Name      Module Name     */
	AUTH_DROP_VTABLE         AuthorizerActionCode = 30 /* Table Name      Module Name     */
	AUTH_FUNCTION            AuthorizerActionCode = 31 /* NULL            Function Name   */
	AUTH_SAVEPOINT           AuthorizerActionCode = 32 /* Operation       Savepoint Name  */
	AUTH_RECURSIVE           AuthorizerActionCode = 33 /* NULL            NULL            */

)

type AuthorizerReturnCode added in v0.12.1

type AuthorizerReturnCode uint32

AuthorizerReturnCode are the integer codes that the authorizer callback may return.

https://sqlite.org/c3ref/c_deny.html

const (
	AUTH_OK     AuthorizerReturnCode = 0
	AUTH_DENY   AuthorizerReturnCode = 1 /* Abort the SQL statement with an error */
	AUTH_IGNORE AuthorizerReturnCode = 2 /* Don't allow access, but don't generate an error */
)

type Backup added in v0.4.2

type Backup struct {
	// contains filtered or unexported fields
}

Backup is an handle to an ongoing online backup operation.

https://sqlite.org/c3ref/backup.html

func (*Backup) Close added in v0.4.2

func (b *Backup) Close() error

Close finishes a backup operation.

It is safe to close a nil, zero or closed Backup.

https://sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish

func (*Backup) PageCount added in v0.4.2

func (b *Backup) PageCount() int

PageCount returns the total number of pages in the source database at the conclusion of the most recent Backup.Step.

https://sqlite.org/c3ref/backup_finish.html#sqlite3backuppagecount

func (*Backup) Remaining added in v0.4.2

func (b *Backup) Remaining() int

Remaining returns the number of pages still to be backed up at the conclusion of the most recent Backup.Step.

https://sqlite.org/c3ref/backup_finish.html#sqlite3backupremaining

func (*Backup) Step added in v0.4.2

func (b *Backup) Step(nPage int) (done bool, err error)

Step copies up to nPage pages between the source and destination databases. If nPage is negative, all remaining source pages are copied.

https://sqlite.org/c3ref/backup_finish.html#sqlite3backupstep

type Blob added in v0.4.0

type Blob struct {
	// contains filtered or unexported fields
}

Blob is an handle to an open BLOB.

It implements io.ReadWriteSeeker for incremental BLOB I/O.

https://sqlite.org/c3ref/blob.html

func (*Blob) Close added in v0.4.0

func (b *Blob) Close() error

Close closes a BLOB handle.

It is safe to close a nil, zero or closed Blob.

https://sqlite.org/c3ref/blob_close.html

func (*Blob) Read added in v0.4.0

func (b *Blob) Read(p []byte) (n int, err error)

Read implements the io.Reader interface.

https://sqlite.org/c3ref/blob_read.html

func (*Blob) ReadFrom added in v0.5.5

func (b *Blob) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom implements the io.ReaderFrom interface.

https://sqlite.org/c3ref/blob_write.html

func (*Blob) Reopen added in v0.4.0

func (b *Blob) Reopen(row int64) error

Reopen moves a BLOB handle to a new row of the same database table.

https://sqlite.org/c3ref/blob_reopen.html

func (*Blob) Seek added in v0.4.0

func (b *Blob) Seek(offset int64, whence int) (int64, error)

Seek implements the io.Seeker interface.

func (*Blob) Size added in v0.4.0

func (b *Blob) Size() int64

Size returns the size of the BLOB in bytes.

https://sqlite.org/c3ref/blob_bytes.html

func (*Blob) Write added in v0.4.0

func (b *Blob) Write(p []byte) (n int, err error)

Write implements the io.Writer interface.

https://sqlite.org/c3ref/blob_write.html

func (*Blob) WriteTo added in v0.5.5

func (b *Blob) WriteTo(w io.Writer) (n int64, err error)

WriteTo implements the io.WriterTo interface.

https://sqlite.org/c3ref/blob_read.html

type CheckpointMode added in v0.14.0

type CheckpointMode uint32

CheckpointMode are all the checkpoint mode values.

https://sqlite.org/c3ref/c_checkpoint_full.html

const (
	CHECKPOINT_PASSIVE  CheckpointMode = 0 /* Do as much as possible w/o blocking */
	CHECKPOINT_FULL     CheckpointMode = 1 /* Wait for writers, then checkpoint */
	CHECKPOINT_RESTART  CheckpointMode = 2 /* Like FULL but wait for readers */
	CHECKPOINT_TRUNCATE CheckpointMode = 3 /* Like RESTART but also truncate WAL */
)

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn is a database connection handle. A Conn is not safe for concurrent use by multiple goroutines.

https://sqlite.org/c3ref/sqlite3.html

func Open

func Open(filename string) (*Conn, error)

Open calls OpenFlags with OPEN_READWRITE, OPEN_CREATE and OPEN_URI.

func OpenContext added in v0.19.0

func OpenContext(ctx context.Context, filename string) (*Conn, error)

OpenContext is like Open but includes a context, which is used to interrupt the process of opening the connectiton.

func OpenFlags

func OpenFlags(filename string, flags OpenFlag) (*Conn, error)

OpenFlags opens an SQLite database file as specified by the filename argument.

If none of the required flags are used, a combination of OPEN_READWRITE and OPEN_CREATE is used. If a URI filename is used, PRAGMA statements to execute can be specified using "_pragma":

sqlite3.Open("file:demo.db?_pragma=busy_timeout(10000)")

https://sqlite.org/c3ref/open.html

func (Conn) AnyCollationNeeded added in v0.8.2

func (c Conn) AnyCollationNeeded() error

AnyCollationNeeded uses Conn.CollationNeeded to register a fake collating function for any unknown collating sequence. The fake collating function works like BINARY.

This can be used to load schemas that contain one or more unknown collating sequences.

func (*Conn) AutoVacuumPages added in v0.14.0

func (c *Conn) AutoVacuumPages(cb func(schema string, dbPages, freePages, bytesPerPage uint) uint) error

AutoVacuumPages registers a autovacuum compaction amount callback.

https://sqlite.org/c3ref/autovacuum_pages.html

func (*Conn) Backup added in v0.4.2

func (src *Conn) Backup(srcDB, dstURI string) error

Backup backs up srcDB on the src connection to the "main" database in dstURI.

Backup opens the SQLite database file dstURI, and blocks until the entire backup is complete. Use Conn.BackupInit for incremental backup.

https://sqlite.org/backup.html

func (*Conn) BackupInit added in v0.4.2

func (src *Conn) BackupInit(srcDB, dstURI string) (*Backup, error)

BackupInit initializes a backup operation to copy the content of one database into another.

BackupInit opens the SQLite database file dstURI, then initializes a backup that copies the contents of srcDB on the src connection to the "main" database in dstURI.

https://sqlite.org/c3ref/backup_finish.html#sqlite3backupinit

func (*Conn) Begin added in v0.4.0

func (c *Conn) Begin() Txn

Begin starts a deferred transaction.

https://sqlite.org/lang_transaction.html

func (*Conn) BeginConcurrent added in v0.18.0

func (c *Conn) BeginConcurrent() (Txn, error)

BeginConcurrent starts a concurrent transaction.

Experimental: requires a custom build of SQLite.

https://sqlite.org/cgi/src/doc/begin-concurrent/doc/begin_concurrent.md

func (*Conn) BeginExclusive added in v0.4.0

func (c *Conn) BeginExclusive() (Txn, error)

BeginExclusive starts an exclusive transaction.

https://sqlite.org/lang_transaction.html

func (*Conn) BeginImmediate added in v0.4.0

func (c *Conn) BeginImmediate() (Txn, error)

BeginImmediate starts an immediate transaction.

https://sqlite.org/lang_transaction.html

func (*Conn) BusyHandler added in v0.12.2

func (c *Conn) BusyHandler(cb func(ctx context.Context, count int) (retry bool)) error

BusyHandler registers a callback to handle BUSY errors.

https://sqlite.org/c3ref/busy_handler.html

func (*Conn) BusyTimeout added in v0.12.2

func (c *Conn) BusyTimeout(timeout time.Duration) error

BusyTimeout sets a busy timeout.

https://sqlite.org/c3ref/busy_timeout.html

func (*Conn) CacheFlush added in v0.18.0

func (c *Conn) CacheFlush() error

CacheFlush flushes caches to disk mid-transaction.

https://sqlite.org/c3ref/db_cacheflush.html

func (*Conn) Changes added in v0.2.0

func (c *Conn) Changes() int64

Changes returns the number of rows modified, inserted or deleted by the most recently completed INSERT, UPDATE or DELETE statement on the database connection.

https://sqlite.org/c3ref/changes.html

func (*Conn) Close

func (c *Conn) Close() error

Close closes the database connection.

If the database connection is associated with unfinalized prepared statements, open blob handles, and/or unfinished backup objects, Close will leave the database connection open and return BUSY.

It is safe to close a nil, zero or closed Conn.

https://sqlite.org/c3ref/close.html

func (*Conn) CollationNeeded added in v0.12.1

func (c *Conn) CollationNeeded(cb func(db *Conn, name string)) error

CollationNeeded registers a callback to be invoked whenever an unknown collation sequence is required.

https://sqlite.org/c3ref/collation_needed.html

func (*Conn) CommitHook added in v0.12.1

func (c *Conn) CommitHook(cb func() (ok bool))

CommitHook registers a callback function to be invoked whenever a transaction is committed. Return true to allow the commit operation to continue normally.

https://sqlite.org/c3ref/commit_hook.html

func (*Conn) Config added in v0.12.0

func (c *Conn) Config(op DBConfig, arg ...bool) (bool, error)

Config makes configuration changes to a database connection. Only boolean configuration options are supported. Called with no arg reads the current configuration value, called with one arg sets and returns the new value.

https://sqlite.org/c3ref/db_config.html

func (*Conn) ConfigLog added in v0.12.0

func (c *Conn) ConfigLog(cb func(code ExtendedErrorCode, msg string)) error

ConfigLog sets up the error logging callback for the connection.

https://sqlite.org/errlog.html

func (*Conn) CreateCollation added in v0.8.2

func (c *Conn) CreateCollation(name string, fn func(a, b []byte) int) error

CreateCollation defines a new collating sequence.

https://sqlite.org/c3ref/create_collation.html

Example
db, err := sqlite3.Open(":memory:")
if err != nil {
	log.Fatal(err)
}
defer db.Close()

err = db.Exec(`CREATE TABLE words (word VARCHAR(10))`)
if err != nil {
	log.Fatal(err)
}

err = db.Exec(`INSERT INTO words (word) VALUES ('côte'), ('cote'), ('coter'), ('coté'), ('cotée'), ('côté')`)
if err != nil {
	log.Fatal(err)
}

err = db.CollationNeeded(func(db *sqlite3.Conn, name string) {
	err := unicode.RegisterCollation(db, name, name)
	if err != nil {
		log.Fatal(err)
	}
})
if err != nil {
	log.Fatal(err)
}

stmt, _, err := db.Prepare(`SELECT word FROM words ORDER BY word COLLATE fr_FR`)
if err != nil {
	log.Fatal(err)
}
defer stmt.Close()

for stmt.Step() {
	fmt.Println(stmt.ColumnText(0))
}
if err := stmt.Err(); err != nil {
	log.Fatal(err)
}
Output:

cote
coté
côte
côté
cotée
coter

func (*Conn) CreateFunction added in v0.8.2

func (c *Conn) CreateFunction(name string, nArg int, flag FunctionFlag, fn ScalarFunction) error

CreateFunction defines a new scalar SQL function.

https://sqlite.org/c3ref/create_function.html

Example
db, err := sqlite3.Open(":memory:")
if err != nil {
	log.Fatal(err)
}
defer db.Close()

err = db.Exec(`CREATE TABLE words (word VARCHAR(10))`)
if err != nil {
	log.Fatal(err)
}

err = db.Exec(`INSERT INTO words (word) VALUES ('côte'), ('cote'), ('coter'), ('coté'), ('cotée'), ('côté')`)
if err != nil {
	log.Fatal(err)
}

err = db.CreateFunction("upper", 1, sqlite3.DETERMINISTIC|sqlite3.INNOCUOUS, func(ctx sqlite3.Context, arg ...sqlite3.Value) {
	ctx.ResultRawText(bytes.ToUpper(arg[0].RawText()))
})
if err != nil {
	log.Fatal(err)
}

stmt, _, err := db.Prepare(`SELECT upper(word) FROM words`)
if err != nil {
	log.Fatal(err)
}
defer stmt.Close()

for stmt.Step() {
	fmt.Println(stmt.ColumnText(0))
}
if err := stmt.Err(); err != nil {
	log.Fatal(err)
}
Output:

COTE
COTÉ
CÔTE
CÔTÉ
COTÉE
COTER

func (*Conn) CreateWindowFunction added in v0.8.2

func (c *Conn) CreateWindowFunction(name string, nArg int, flag FunctionFlag, fn func() AggregateFunction) error

CreateWindowFunction defines a new aggregate or aggregate window SQL function. If fn returns a WindowFunction, then an aggregate window function is created. If fn returns an io.Closer, it will be called to free resources.

https://sqlite.org/c3ref/create_function.html

Example
package main

import (
	"fmt"
	"log"
	"unicode"

	"github.com/ncruces/go-sqlite3"
	_ "github.com/ncruces/go-sqlite3/embed"
)

func main() {
	db, err := sqlite3.Open(":memory:")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	err = db.Exec(`CREATE TABLE words (word VARCHAR(10))`)
	if err != nil {
		log.Fatal(err)
	}

	err = db.Exec(`INSERT INTO words (word) VALUES ('côte'), ('cote'), ('coter'), ('coté'), ('cotée'), ('côté')`)
	if err != nil {
		log.Fatal(err)
	}

	err = db.CreateWindowFunction("count_ascii", 1, sqlite3.DETERMINISTIC|sqlite3.INNOCUOUS, newASCIICounter)
	if err != nil {
		log.Fatal(err)
	}

	stmt, _, err := db.Prepare(`SELECT count_ascii(word) OVER (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM words`)
	if err != nil {
		log.Fatal(err)
	}
	defer stmt.Close()

	for stmt.Step() {
		fmt.Println(stmt.ColumnInt(0))
	}
	if err := stmt.Err(); err != nil {
		log.Fatal(err)
	}
}

type countASCII struct{ result int }

func newASCIICounter() sqlite3.AggregateFunction {
	return &countASCII{}
}

func (f *countASCII) Value(ctx sqlite3.Context) {
	ctx.ResultInt(f.result)
}

func (f *countASCII) Step(ctx sqlite3.Context, arg ...sqlite3.Value) {
	if f.isASCII(arg[0]) {
		f.result++
	}
}

func (f *countASCII) Inverse(ctx sqlite3.Context, arg ...sqlite3.Value) {
	if f.isASCII(arg[0]) {
		f.result--
	}
}

func (f *countASCII) isASCII(arg sqlite3.Value) bool {
	if arg.Type() != sqlite3.TEXT {
		return false
	}
	for _, c := range arg.RawText() {
		if c > unicode.MaxASCII {
			return false
		}
	}
	return true
}
Output:

1
2
2
1
0
0

func (*Conn) DBName added in v0.12.1

func (c *Conn) DBName(n int) string

DBName returns the schema name for n-th database on the database connection.

https://sqlite.org/c3ref/db_name.html

func (*Conn) DeclareVTab added in v0.12.0

func (c *Conn) DeclareVTab(sql string) error

DeclareVTab declares the schema of a virtual table.

https://sqlite.org/c3ref/declare_vtab.html

func (*Conn) EnableChecksums added in v0.20.0

func (c *Conn) EnableChecksums(schema string) error

EnableChecksums enables checksums on a database.

https://sqlite.org/cksumvfs.html

func (*Conn) Exec

func (c *Conn) Exec(sql string) error

Exec is a convenience function that allows an application to run multiple statements of SQL without having to use a lot of code.

https://sqlite.org/c3ref/exec.html

func (*Conn) FileControl added in v0.18.0

func (c *Conn) FileControl(schema string, op FcntlOpcode, arg ...any) (any, error)

FileControl allows low-level control of database files. Only a subset of opcodes are supported.

https://sqlite.org/c3ref/file_control.html

func (*Conn) Filename added in v0.15.0

func (c *Conn) Filename(schema string) *vfs.Filename

Filename returns the filename for a database.

https://sqlite.org/c3ref/db_filename.html

func (*Conn) GetAutocommit added in v0.4.0

func (c *Conn) GetAutocommit() bool

GetAutocommit tests the connection for auto-commit mode.

https://sqlite.org/c3ref/get_autocommit.html

func (*Conn) GetInterrupt added in v0.14.0

func (c *Conn) GetInterrupt() context.Context

GetInterrupt gets the context set with Conn.SetInterrupt.

func (*Conn) HardHeapLimit added in v0.18.3

func (c *Conn) HardHeapLimit(n int64) int64

HardHeapLimit imposes a hard limit on heap size.

https://sqlite.org/c3ref/hard_heap_limit64.html

func (*Conn) LastInsertRowID added in v0.2.0

func (c *Conn) LastInsertRowID() int64

LastInsertRowID returns the rowid of the most recent successful INSERT on the database connection.

https://sqlite.org/c3ref/last_insert_rowid.html

func (*Conn) Limit added in v0.12.1

func (c *Conn) Limit(id LimitCategory, value int) int

Limit allows the size of various constructs to be limited on a connection by connection basis.

https://sqlite.org/c3ref/limit.html

func (*Conn) Log added in v0.20.2

func (c *Conn) Log(code ExtendedErrorCode, format string, a ...any)

Log writes a message into the error log established by Conn.ConfigLog.

https://sqlite.org/c3ref/log.html

func (*Conn) OpenBlob added in v0.4.0

func (c *Conn) OpenBlob(db, table, column string, row int64, write bool) (*Blob, error)

OpenBlob opens a BLOB for incremental I/O.

https://sqlite.org/c3ref/blob_open.html

func (*Conn) OverloadFunction added in v0.12.0

func (c *Conn) OverloadFunction(name string, nArg int) error

OverloadFunction overloads a function for a virtual table.

https://sqlite.org/c3ref/overload_function.html

func (*Conn) Prepare

func (c *Conn) Prepare(sql string) (stmt *Stmt, tail string, err error)

Prepare calls Conn.PrepareFlags with no flags.

func (*Conn) PrepareFlags

func (c *Conn) PrepareFlags(sql string, flags PrepareFlag) (stmt *Stmt, tail string, err error)

PrepareFlags compiles the first SQL statement in sql; tail is left pointing to what remains uncompiled. If the input text contains no SQL (if the input is an empty string or a comment), both stmt and err will be nil.

https://sqlite.org/c3ref/prepare.html

func (*Conn) ReadOnly added in v0.12.1

func (c *Conn) ReadOnly(schema string) (ro bool, ok bool)

ReadOnly determines if a database is read-only.

https://sqlite.org/c3ref/db_readonly.html

func (*Conn) ReleaseMemory added in v0.12.1

func (c *Conn) ReleaseMemory() error

ReleaseMemory frees memory used by a database connection.

https://sqlite.org/c3ref/db_release_memory.html

func (*Conn) Restore added in v0.4.2

func (dst *Conn) Restore(dstDB, srcURI string) error

Restore restores dstDB on the dst connection from the "main" database in srcURI.

Restore opens the SQLite database file srcURI, and blocks until the entire restore is complete.

https://sqlite.org/backup.html

func (*Conn) RollbackHook added in v0.12.1

func (c *Conn) RollbackHook(cb func())

RollbackHook registers a callback function to be invoked whenever a transaction is rolled back.

https://sqlite.org/c3ref/commit_hook.html

func (*Conn) Savepoint added in v0.4.0

func (c *Conn) Savepoint() Savepoint

Savepoint establishes a new transaction savepoint.

https://sqlite.org/lang_savepoint.html

func (*Conn) SetAuthorizer added in v0.12.1

func (c *Conn) SetAuthorizer(cb func(action AuthorizerActionCode, name3rd, name4th, schema, inner string) AuthorizerReturnCode) error

SetAuthorizer registers an authorizer callback with the database connection.

https://sqlite.org/c3ref/set_authorizer.html

func (*Conn) SetInterrupt added in v0.2.0

func (c *Conn) SetInterrupt(ctx context.Context) (old context.Context)

SetInterrupt interrupts a long-running query when a context is done.

Subsequent uses of the connection will return INTERRUPT until the context is reset by another call to SetInterrupt.

To associate a timeout with a connection:

ctx, cancel := context.WithTimeout(context.TODO(), 100*time.Millisecond)
conn.SetInterrupt(ctx)
defer cancel()

SetInterrupt returns the old context assigned to the connection.

https://sqlite.org/c3ref/interrupt.html

func (*Conn) SetLastInsertRowID added in v0.12.1

func (c *Conn) SetLastInsertRowID(id int64)

SetLastInsertRowID allows the application to set the value returned by Conn.LastInsertRowID.

https://sqlite.org/c3ref/set_last_insert_rowid.html

func (*Conn) SoftHeapLimit added in v0.18.3

func (c *Conn) SoftHeapLimit(n int64) int64

SoftHeapLimit imposes a soft limit on heap size.

https://sqlite.org/c3ref/hard_heap_limit64.html

func (*Conn) Status added in v0.18.0

func (c *Conn) Status(op DBStatus, reset bool) (current, highwater int, err error)

Status retrieves runtime status information about a database connection.

https://sqlite.org/c3ref/db_status.html

func (*Conn) Stmts added in v0.18.0

func (c *Conn) Stmts() iter.Seq[*Stmt]

Stmts returns an iterator for the prepared statements associated with the database connection.

https://sqlite.org/c3ref/next_stmt.html

func (*Conn) TableColumnMetadata added in v0.18.0

func (c *Conn) TableColumnMetadata(schema, table, column string) (declType, collSeq string, notNull, primaryKey, autoInc bool, err error)

TableColumnMetadata extracts metadata about a column of a table.

https://sqlite.org/c3ref/table_column_metadata.html

func (*Conn) TotalChanges added in v0.12.1

func (c *Conn) TotalChanges() int64

TotalChanges returns the number of rows modified, inserted or deleted by all INSERT, UPDATE or DELETE statements completed since the database connection was opened.

https://sqlite.org/c3ref/total_changes.html

func (*Conn) Trace added in v0.18.0

func (c *Conn) Trace(mask TraceEvent, cb func(evt TraceEvent, arg1 any, arg2 any) error) error

Trace registers a trace callback function against the database connection.

https://sqlite.org/c3ref/trace_v2.html

func (*Conn) TxnState added in v0.12.1

func (c *Conn) TxnState(schema string) TxnState

TxnState determines the transaction state of a database.

https://sqlite.org/c3ref/txn_state.html

func (*Conn) UpdateHook added in v0.12.1

func (c *Conn) UpdateHook(cb func(action AuthorizerActionCode, schema, table string, rowid int64))

UpdateHook registers a callback function to be invoked whenever a row is updated, inserted or deleted in a rowid table.

https://sqlite.org/c3ref/update_hook.html

func (*Conn) VTabConfig added in v0.12.0

func (c *Conn) VTabConfig(op VTabConfigOption, args ...any) error

VTabConfig configures various facets of the virtual table interface.

https://sqlite.org/c3ref/vtab_config.html

func (*Conn) VTabOnConflict added in v0.12.0

func (c *Conn) VTabOnConflict() VTabConflictMode

VTabOnConflict determines the virtual table conflict policy.

https://sqlite.org/c3ref/vtab_on_conflict.html

func (*Conn) WALAutoCheckpoint added in v0.20.0

func (c *Conn) WALAutoCheckpoint(pages int) error

WALAutoCheckpoint configures WAL auto-checkpoints.

https://sqlite.org/c3ref/wal_autocheckpoint.html

func (*Conn) WALCheckpoint added in v0.20.0

func (c *Conn) WALCheckpoint(schema string, mode CheckpointMode) (nLog, nCkpt int, err error)

WALCheckpoint checkpoints a WAL database.

https://sqlite.org/c3ref/wal_checkpoint_v2.html

func (*Conn) WALHook added in v0.20.0

func (c *Conn) WALHook(cb func(db *Conn, schema string, pages int) error)

WALHook registers a callback function to be invoked each time data is committed to a database in WAL mode.

https://sqlite.org/c3ref/wal_hook.html

type Context added in v0.8.2

type Context struct {
	// contains filtered or unexported fields
}

Context is the context in which an SQL function executes. An SQLite Context is in no way related to a Go context.Context.

https://sqlite.org/c3ref/context.html

func (Context) Conn added in v0.10.1

func (ctx Context) Conn() *Conn

Conn returns the database connection of the Conn.CreateFunction or Conn.CreateWindowFunction routines that originally registered the application defined function.

https://sqlite.org/c3ref/context_db_handle.html

func (Context) GetAuxData added in v0.8.2

func (ctx Context) GetAuxData(n int) any

GetAuxData returns metadata for argument n of the function.

https://sqlite.org/c3ref/get_auxdata.html

func (Context) ResultBlob added in v0.8.2

func (ctx Context) ResultBlob(value []byte)

ResultBlob sets the result of the function to a []byte. Returning a nil slice is the same as calling Context.ResultNull.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultBool added in v0.8.2

func (ctx Context) ResultBool(value bool)

ResultBool sets the result of the function to a bool. SQLite does not have a separate boolean storage class. Instead, boolean values are stored as integers 0 (false) and 1 (true).

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultError added in v0.8.2

func (ctx Context) ResultError(err error)

ResultError sets the result of the function an error.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultFloat added in v0.8.2

func (ctx Context) ResultFloat(value float64)

ResultFloat sets the result of the function to a float64.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultInt added in v0.8.2

func (ctx Context) ResultInt(value int)

ResultInt sets the result of the function to an int.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultInt64 added in v0.8.2

func (ctx Context) ResultInt64(value int64)

ResultInt64 sets the result of the function to an int64.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultJSON added in v0.10.0

func (ctx Context) ResultJSON(value any)

ResultJSON sets the result of the function to the JSON encoding of value.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultNull added in v0.8.2

func (ctx Context) ResultNull()

ResultNull sets the result of the function to NULL.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultPointer added in v0.10.1

func (ctx Context) ResultPointer(ptr any)

ResultPointer sets the result of the function to NULL, just like Context.ResultNull, except that it also associates ptr with that NULL value such that it can be retrieved within an application-defined SQL function using Value.Pointer.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultRawText added in v0.10.3

func (ctx Context) ResultRawText(value []byte)

ResultRawText sets the text result of the function to a []byte. Returning a nil slice is the same as calling Context.ResultNull.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultText added in v0.8.2

func (ctx Context) ResultText(value string)

ResultText sets the result of the function to a string.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultTime added in v0.8.2

func (ctx Context) ResultTime(value time.Time, format TimeFormat)

ResultTime sets the result of the function to a time.Time.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultValue added in v0.10.0

func (ctx Context) ResultValue(value Value)

ResultValue sets the result of the function to a copy of Value.

https://sqlite.org/c3ref/result_blob.html

func (Context) ResultZeroBlob added in v0.8.2

func (ctx Context) ResultZeroBlob(n int64)

ResultZeroBlob sets the result of the function to a zero-filled, length n BLOB.

https://sqlite.org/c3ref/result_blob.html

func (Context) SetAuxData added in v0.8.2

func (ctx Context) SetAuxData(n int, data any)

SetAuxData saves metadata for argument n of the function.

https://sqlite.org/c3ref/get_auxdata.html

Example
db, err := sqlite3.Open(":memory:")
if err != nil {
	log.Fatal(err)
}
defer db.Close()

err = db.Exec(`CREATE TABLE words (word VARCHAR(10))`)
if err != nil {
	log.Fatal(err)
}

err = db.Exec(`INSERT INTO words (word) VALUES ('côte'), ('cote'), ('coter'), ('coté'), ('cotée'), ('côté')`)
if err != nil {
	log.Fatal(err)
}

err = db.CreateFunction("regexp", 2, sqlite3.DETERMINISTIC|sqlite3.INNOCUOUS, func(ctx sqlite3.Context, arg ...sqlite3.Value) {
	re, ok := ctx.GetAuxData(0).(*regexp.Regexp)
	if !ok {
		r, err := regexp.Compile(arg[0].Text())
		if err != nil {
			ctx.ResultError(err)
			return
		}
		re = r
		ctx.SetAuxData(0, r)
	}
	ctx.ResultBool(re.Match(arg[1].RawText()))
})
if err != nil {
	log.Fatal(err)
}

stmt, _, err := db.Prepare(`SELECT word FROM words WHERE word REGEXP '^\p{L}+e$'`)
if err != nil {
	log.Fatal(err)
}
defer stmt.Close()

for stmt.Step() {
	fmt.Println(stmt.ColumnText(0))
}
if err := stmt.Err(); err != nil {
	log.Fatal(err)
}
Output:

cote
côte
cotée

func (Context) VTabNoChange added in v0.12.0

func (ctx Context) VTabNoChange() bool

VTabNoChange may return true if a column is being fetched as part of an update during which the column value will not change.

https://sqlite.org/c3ref/vtab_nochange.html

type DBConfig added in v0.12.0

type DBConfig uint32

DBConfig are the available database connection configuration options.

https://sqlite.org/c3ref/c_dbconfig_defensive.html

const (
	// DBCONFIG_MAINDBNAME         DBConfig = 1000
	// DBCONFIG_LOOKASIDE          DBConfig = 1001
	DBCONFIG_ENABLE_FKEY           DBConfig = 1002
	DBCONFIG_ENABLE_TRIGGER        DBConfig = 1003
	DBCONFIG_ENABLE_FTS3_TOKENIZER DBConfig = 1004
	DBCONFIG_ENABLE_LOAD_EXTENSION DBConfig = 1005
	DBCONFIG_NO_CKPT_ON_CLOSE      DBConfig = 1006
	DBCONFIG_ENABLE_QPSG           DBConfig = 1007
	DBCONFIG_TRIGGER_EQP           DBConfig = 1008
	DBCONFIG_RESET_DATABASE        DBConfig = 1009
	DBCONFIG_DEFENSIVE             DBConfig = 1010
	DBCONFIG_WRITABLE_SCHEMA       DBConfig = 1011
	DBCONFIG_LEGACY_ALTER_TABLE    DBConfig = 1012
	DBCONFIG_DQS_DML               DBConfig = 1013
	DBCONFIG_DQS_DDL               DBConfig = 1014
	DBCONFIG_ENABLE_VIEW           DBConfig = 1015
	DBCONFIG_LEGACY_FILE_FORMAT    DBConfig = 1016
	DBCONFIG_TRUSTED_SCHEMA        DBConfig = 1017
	DBCONFIG_STMT_SCANSTATUS       DBConfig = 1018
	DBCONFIG_REVERSE_SCANORDER     DBConfig = 1019
)

type DBStatus added in v0.18.0

type DBStatus uint32

DBStatus are the available "verbs" that can be passed to the Conn.Status method.

https://sqlite.org/c3ref/c_dbstatus_options.html

const (
	DBSTATUS_LOOKASIDE_USED      DBStatus = 0
	DBSTATUS_CACHE_USED          DBStatus = 1
	DBSTATUS_SCHEMA_USED         DBStatus = 2
	DBSTATUS_STMT_USED           DBStatus = 3
	DBSTATUS_LOOKASIDE_HIT       DBStatus = 4
	DBSTATUS_LOOKASIDE_MISS_SIZE DBStatus = 5
	DBSTATUS_LOOKASIDE_MISS_FULL DBStatus = 6
	DBSTATUS_CACHE_HIT           DBStatus = 7
	DBSTATUS_CACHE_MISS          DBStatus = 8
	DBSTATUS_CACHE_WRITE         DBStatus = 9
	DBSTATUS_DEFERRED_FKS        DBStatus = 10
	DBSTATUS_CACHE_USED_SHARED   DBStatus = 11
	DBSTATUS_CACHE_SPILL         DBStatus = 12
)

type Datatype

type Datatype uint32

Datatype is a fundamental datatype of SQLite.

https://sqlite.org/c3ref/c_blob.html

const (
	INTEGER Datatype = 1
	FLOAT   Datatype = 2
	TEXT    Datatype = 3
	BLOB    Datatype = 4
	NULL    Datatype = 5
)

func (Datatype) String

func (t Datatype) String() string

String implements the fmt.Stringer interface.

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error wraps an SQLite Error Code.

https://sqlite.org/c3ref/errcode.html

func (*Error) As added in v0.8.2

func (e *Error) As(err any) bool

As converts this error to an ErrorCode or ExtendedErrorCode.

func (*Error) Code

func (e *Error) Code() ErrorCode

Code returns the primary error code for this error.

https://sqlite.org/rescode.html

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) ExtendedCode

func (e *Error) ExtendedCode() ExtendedErrorCode

ExtendedCode returns the extended error code for this error.

https://sqlite.org/rescode.html

func (*Error) Is added in v0.4.0

func (e *Error) Is(err error) bool

Is tests whether this error matches a given ErrorCode or ExtendedErrorCode.

It makes it possible to do:

if errors.Is(err, sqlite3.BUSY) {
	// ... handle BUSY
}

func (*Error) SQL

func (e *Error) SQL() string

SQL returns the SQL starting at the token that triggered a syntax error.

func (*Error) Temporary added in v0.3.0

func (e *Error) Temporary() bool

Temporary returns true for BUSY errors.

func (*Error) Timeout added in v0.4.0

func (e *Error) Timeout() bool

Timeout returns true for BUSY_TIMEOUT errors.

type ErrorCode

type ErrorCode uint8

ErrorCode is a result code that Error.Code might return.

https://sqlite.org/rescode.html

const (
	ERROR      ErrorCode = 1  /* Generic error */
	INTERNAL   ErrorCode = 2  /* Internal logic error in SQLite */
	PERM       ErrorCode = 3  /* Access permission denied */
	ABORT      ErrorCode = 4  /* Callback routine requested an abort */
	BUSY       ErrorCode = 5  /* The database file is locked */
	LOCKED     ErrorCode = 6  /* A table in the database is locked */
	NOMEM      ErrorCode = 7  /* A malloc() failed */
	READONLY   ErrorCode = 8  /* Attempt to write a readonly database */
	INTERRUPT  ErrorCode = 9  /* Operation terminated by sqlite3_interrupt() */
	IOERR      ErrorCode = 10 /* Some kind of disk I/O error occurred */
	CORRUPT    ErrorCode = 11 /* The database disk image is malformed */
	NOTFOUND   ErrorCode = 12 /* Unknown opcode in sqlite3_file_control() */
	FULL       ErrorCode = 13 /* Insertion failed because database is full */
	CANTOPEN   ErrorCode = 14 /* Unable to open the database file */
	PROTOCOL   ErrorCode = 15 /* Database lock protocol error */
	EMPTY      ErrorCode = 16 /* Internal use only */
	SCHEMA     ErrorCode = 17 /* The database schema changed */
	TOOBIG     ErrorCode = 18 /* String or BLOB exceeds size limit */
	CONSTRAINT ErrorCode = 19 /* Abort due to constraint violation */
	MISMATCH   ErrorCode = 20 /* Data type mismatch */
	MISUSE     ErrorCode = 21 /* Library used incorrectly */
	NOLFS      ErrorCode = 22 /* Uses OS features not supported on host */
	AUTH       ErrorCode = 23 /* Authorization denied */
	FORMAT     ErrorCode = 24 /* Not used */
	RANGE      ErrorCode = 25 /* 2nd parameter to sqlite3_bind out of range */
	NOTADB     ErrorCode = 26 /* File opened that is not a database file */
	NOTICE     ErrorCode = 27 /* Notifications from sqlite3_log() */
	WARNING    ErrorCode = 28 /* Warnings from sqlite3_log() */
)

func (ErrorCode) Error added in v0.4.0

func (e ErrorCode) Error() string

Error implements the error interface.

func (ErrorCode) ExtendedCode added in v0.20.2

func (e ErrorCode) ExtendedCode() ExtendedErrorCode

ExtendedCode returns the extended error code for this error.

func (ErrorCode) Temporary added in v0.4.0

func (e ErrorCode) Temporary() bool

Temporary returns true for BUSY errors.

type ExtendedErrorCode

type ExtendedErrorCode uint16

ExtendedErrorCode is a result code that Error.ExtendedCode might return.

https://sqlite.org/rescode.html

const (
	ERROR_MISSING_COLLSEQ   ExtendedErrorCode = xErrorCode(ERROR) | (1 << 8)
	ERROR_RETRY             ExtendedErrorCode = xErrorCode(ERROR) | (2 << 8)
	ERROR_SNAPSHOT          ExtendedErrorCode = xErrorCode(ERROR) | (3 << 8)
	IOERR_READ              ExtendedErrorCode = xErrorCode(IOERR) | (1 << 8)
	IOERR_SHORT_READ        ExtendedErrorCode = xErrorCode(IOERR) | (2 << 8)
	IOERR_WRITE             ExtendedErrorCode = xErrorCode(IOERR) | (3 << 8)
	IOERR_FSYNC             ExtendedErrorCode = xErrorCode(IOERR) | (4 << 8)
	IOERR_DIR_FSYNC         ExtendedErrorCode = xErrorCode(IOERR) | (5 << 8)
	IOERR_TRUNCATE          ExtendedErrorCode = xErrorCode(IOERR) | (6 << 8)
	IOERR_FSTAT             ExtendedErrorCode = xErrorCode(IOERR) | (7 << 8)
	IOERR_UNLOCK            ExtendedErrorCode = xErrorCode(IOERR) | (8 << 8)
	IOERR_RDLOCK            ExtendedErrorCode = xErrorCode(IOERR) | (9 << 8)
	IOERR_DELETE            ExtendedErrorCode = xErrorCode(IOERR) | (10 << 8)
	IOERR_BLOCKED           ExtendedErrorCode = xErrorCode(IOERR) | (11 << 8)
	IOERR_NOMEM             ExtendedErrorCode = xErrorCode(IOERR) | (12 << 8)
	IOERR_ACCESS            ExtendedErrorCode = xErrorCode(IOERR) | (13 << 8)
	IOERR_CHECKRESERVEDLOCK ExtendedErrorCode = xErrorCode(IOERR) | (14 << 8)
	IOERR_LOCK              ExtendedErrorCode = xErrorCode(IOERR) | (15 << 8)
	IOERR_CLOSE             ExtendedErrorCode = xErrorCode(IOERR) | (16 << 8)
	IOERR_DIR_CLOSE         ExtendedErrorCode = xErrorCode(IOERR) | (17 << 8)
	IOERR_SHMOPEN           ExtendedErrorCode = xErrorCode(IOERR) | (18 << 8)
	IOERR_SHMSIZE           ExtendedErrorCode = xErrorCode(IOERR) | (19 << 8)
	IOERR_SHMLOCK           ExtendedErrorCode = xErrorCode(IOERR) | (20 << 8)
	IOERR_SHMMAP            ExtendedErrorCode = xErrorCode(IOERR) | (21 << 8)
	IOERR_SEEK              ExtendedErrorCode = xErrorCode(IOERR) | (22 << 8)
	IOERR_DELETE_NOENT      ExtendedErrorCode = xErrorCode(IOERR) | (23 << 8)
	IOERR_MMAP              ExtendedErrorCode = xErrorCode(IOERR) | (24 << 8)
	IOERR_GETTEMPPATH       ExtendedErrorCode = xErrorCode(IOERR) | (25 << 8)
	IOERR_CONVPATH          ExtendedErrorCode = xErrorCode(IOERR) | (26 << 8)
	IOERR_VNODE             ExtendedErrorCode = xErrorCode(IOERR) | (27 << 8)
	IOERR_AUTH              ExtendedErrorCode = xErrorCode(IOERR) | (28 << 8)
	IOERR_BEGIN_ATOMIC      ExtendedErrorCode = xErrorCode(IOERR) | (29 << 8)
	IOERR_COMMIT_ATOMIC     ExtendedErrorCode = xErrorCode(IOERR) | (30 << 8)
	IOERR_ROLLBACK_ATOMIC   ExtendedErrorCode = xErrorCode(IOERR) | (31 << 8)
	IOERR_DATA              ExtendedErrorCode = xErrorCode(IOERR) | (32 << 8)
	IOERR_CORRUPTFS         ExtendedErrorCode = xErrorCode(IOERR) | (33 << 8)
	IOERR_IN_PAGE           ExtendedErrorCode = xErrorCode(IOERR) | (34 << 8)
	LOCKED_SHAREDCACHE      ExtendedErrorCode = xErrorCode(LOCKED) | (1 << 8)
	LOCKED_VTAB             ExtendedErrorCode = xErrorCode(LOCKED) | (2 << 8)
	BUSY_RECOVERY           ExtendedErrorCode = xErrorCode(BUSY) | (1 << 8)
	BUSY_SNAPSHOT           ExtendedErrorCode = xErrorCode(BUSY) | (2 << 8)
	BUSY_TIMEOUT            ExtendedErrorCode = xErrorCode(BUSY) | (3 << 8)
	CANTOPEN_NOTEMPDIR      ExtendedErrorCode = xErrorCode(CANTOPEN) | (1 << 8)
	CANTOPEN_ISDIR          ExtendedErrorCode = xErrorCode(CANTOPEN) | (2 << 8)
	CANTOPEN_FULLPATH       ExtendedErrorCode = xErrorCode(CANTOPEN) | (3 << 8)
	CANTOPEN_CONVPATH       ExtendedErrorCode = xErrorCode(CANTOPEN) | (4 << 8)
	// CANTOPEN_DIRTYWAL    ExtendedErrorCode = xErrorCode(CANTOPEN) | (5 << 8) /* Not Used */
	CANTOPEN_SYMLINK        ExtendedErrorCode = xErrorCode(CANTOPEN) | (6 << 8)
	CORRUPT_VTAB            ExtendedErrorCode = xErrorCode(CORRUPT) | (1 << 8)
	CORRUPT_SEQUENCE        ExtendedErrorCode = xErrorCode(CORRUPT) | (2 << 8)
	CORRUPT_INDEX           ExtendedErrorCode = xErrorCode(CORRUPT) | (3 << 8)
	READONLY_RECOVERY       ExtendedErrorCode = xErrorCode(READONLY) | (1 << 8)
	READONLY_CANTLOCK       ExtendedErrorCode = xErrorCode(READONLY) | (2 << 8)
	READONLY_ROLLBACK       ExtendedErrorCode = xErrorCode(READONLY) | (3 << 8)
	READONLY_DBMOVED        ExtendedErrorCode = xErrorCode(READONLY) | (4 << 8)
	READONLY_CANTINIT       ExtendedErrorCode = xErrorCode(READONLY) | (5 << 8)
	READONLY_DIRECTORY      ExtendedErrorCode = xErrorCode(READONLY) | (6 << 8)
	ABORT_ROLLBACK          ExtendedErrorCode = xErrorCode(ABORT) | (2 << 8)
	CONSTRAINT_CHECK        ExtendedErrorCode = xErrorCode(CONSTRAINT) | (1 << 8)
	CONSTRAINT_COMMITHOOK   ExtendedErrorCode = xErrorCode(CONSTRAINT) | (2 << 8)
	CONSTRAINT_FOREIGNKEY   ExtendedErrorCode = xErrorCode(CONSTRAINT) | (3 << 8)
	CONSTRAINT_FUNCTION     ExtendedErrorCode = xErrorCode(CONSTRAINT) | (4 << 8)
	CONSTRAINT_NOTNULL      ExtendedErrorCode = xErrorCode(CONSTRAINT) | (5 << 8)
	CONSTRAINT_PRIMARYKEY   ExtendedErrorCode = xErrorCode(CONSTRAINT) | (6 << 8)
	CONSTRAINT_TRIGGER      ExtendedErrorCode = xErrorCode(CONSTRAINT) | (7 << 8)
	CONSTRAINT_UNIQUE       ExtendedErrorCode = xErrorCode(CONSTRAINT) | (8 << 8)
	CONSTRAINT_VTAB         ExtendedErrorCode = xErrorCode(CONSTRAINT) | (9 << 8)
	CONSTRAINT_ROWID        ExtendedErrorCode = xErrorCode(CONSTRAINT) | (10 << 8)
	CONSTRAINT_PINNED       ExtendedErrorCode = xErrorCode(CONSTRAINT) | (11 << 8)
	CONSTRAINT_DATATYPE     ExtendedErrorCode = xErrorCode(CONSTRAINT) | (12 << 8)
	NOTICE_RECOVER_WAL      ExtendedErrorCode = xErrorCode(NOTICE) | (1 << 8)
	NOTICE_RECOVER_ROLLBACK ExtendedErrorCode = xErrorCode(NOTICE) | (2 << 8)
	NOTICE_RBU              ExtendedErrorCode = xErrorCode(NOTICE) | (3 << 8)
	WARNING_AUTOINDEX       ExtendedErrorCode = xErrorCode(WARNING) | (1 << 8)
	AUTH_USER               ExtendedErrorCode = xErrorCode(AUTH) | (1 << 8)
)

func (ExtendedErrorCode) As added in v0.8.2

func (e ExtendedErrorCode) As(err any) bool

As converts this error to an ErrorCode.

func (ExtendedErrorCode) Code added in v0.20.2

func (e ExtendedErrorCode) Code() ErrorCode

Code returns the primary error code for this error.

func (ExtendedErrorCode) Error added in v0.4.0

func (e ExtendedErrorCode) Error() string

Error implements the error interface.

func (ExtendedErrorCode) Is added in v0.4.0

func (e ExtendedErrorCode) Is(err error) bool

Is tests whether this error matches a given ErrorCode.

func (ExtendedErrorCode) Temporary added in v0.4.0

func (e ExtendedErrorCode) Temporary() bool

Temporary returns true for BUSY errors.

func (ExtendedErrorCode) Timeout added in v0.4.0

func (e ExtendedErrorCode) Timeout() bool

Timeout returns true for BUSY_TIMEOUT errors.

type FcntlOpcode added in v0.18.0

type FcntlOpcode uint32

FcntlOpcode are the available opcodes for Conn.FileControl.

https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html

const (
	FCNTL_LOCKSTATE           FcntlOpcode = 1
	FCNTL_CHUNK_SIZE          FcntlOpcode = 6
	FCNTL_FILE_POINTER        FcntlOpcode = 7
	FCNTL_PERSIST_WAL         FcntlOpcode = 10
	FCNTL_POWERSAFE_OVERWRITE FcntlOpcode = 13
	FCNTL_VFS_POINTER         FcntlOpcode = 27
	FCNTL_JOURNAL_POINTER     FcntlOpcode = 28
	FCNTL_DATA_VERSION        FcntlOpcode = 35
	FCNTL_RESERVE_BYTES       FcntlOpcode = 38
	FCNTL_RESET_CACHE         FcntlOpcode = 42
)

type FunctionFlag added in v0.8.2

type FunctionFlag uint32

FunctionFlag is a flag that can be passed to Conn.CreateFunction and Conn.CreateWindowFunction.

https://sqlite.org/c3ref/c_deterministic.html

const (
	DETERMINISTIC FunctionFlag = 0x000000800
	DIRECTONLY    FunctionFlag = 0x000080000
	INNOCUOUS     FunctionFlag = 0x000200000
	SELFORDER1    FunctionFlag = 0x002000000
)

type IndexConstraint added in v0.10.3

type IndexConstraint struct {
	Column int
	Op     IndexConstraintOp
	Usable bool
}

An IndexConstraint describes virtual table indexing constraint information.

https://sqlite.org/c3ref/index_info.html

type IndexConstraintOp added in v0.10.3

type IndexConstraintOp uint8

IndexConstraintOp is a virtual table constraint operator code.

https://sqlite.org/c3ref/c_index_constraint_eq.html

const (
	INDEX_CONSTRAINT_EQ        IndexConstraintOp = 2
	INDEX_CONSTRAINT_GT        IndexConstraintOp = 4
	INDEX_CONSTRAINT_LE        IndexConstraintOp = 8
	INDEX_CONSTRAINT_LT        IndexConstraintOp = 16
	INDEX_CONSTRAINT_GE        IndexConstraintOp = 32
	INDEX_CONSTRAINT_MATCH     IndexConstraintOp = 64
	INDEX_CONSTRAINT_LIKE      IndexConstraintOp = 65
	INDEX_CONSTRAINT_GLOB      IndexConstraintOp = 66
	INDEX_CONSTRAINT_REGEXP    IndexConstraintOp = 67
	INDEX_CONSTRAINT_NE        IndexConstraintOp = 68
	INDEX_CONSTRAINT_ISNOT     IndexConstraintOp = 69
	INDEX_CONSTRAINT_ISNOTNULL IndexConstraintOp = 70
	INDEX_CONSTRAINT_ISNULL    IndexConstraintOp = 71
	INDEX_CONSTRAINT_IS        IndexConstraintOp = 72
	INDEX_CONSTRAINT_LIMIT     IndexConstraintOp = 73
	INDEX_CONSTRAINT_OFFSET    IndexConstraintOp = 74
	INDEX_CONSTRAINT_FUNCTION  IndexConstraintOp = 150
)

type IndexConstraintUsage added in v0.10.3

type IndexConstraintUsage struct {
	ArgvIndex int
	Omit      bool
}

An IndexConstraintUsage describes how virtual table indexing constraints will be used.

https://sqlite.org/c3ref/index_info.html

type IndexInfo added in v0.10.3

type IndexInfo struct {
	// Inputs
	Constraint  []IndexConstraint
	OrderBy     []IndexOrderBy
	ColumnsUsed int64
	// Outputs
	ConstraintUsage []IndexConstraintUsage
	IdxNum          int
	IdxStr          string
	IdxFlags        IndexScanFlag
	OrderByConsumed bool
	EstimatedCost   float64
	EstimatedRows   int64
	// contains filtered or unexported fields
}

An IndexInfo describes virtual table indexing information.

https://sqlite.org/c3ref/index_info.html

func (*IndexInfo) Collation added in v0.12.0

func (idx *IndexInfo) Collation(column int) string

Collation returns the name of the collation for a virtual table constraint.

https://sqlite.org/c3ref/vtab_collation.html

func (*IndexInfo) Distinct added in v0.12.0

func (idx *IndexInfo) Distinct() int

Distinct determines if a virtual table query is DISTINCT.

https://sqlite.org/c3ref/vtab_distinct.html

func (*IndexInfo) In added in v0.12.0

func (idx *IndexInfo) In(column, handle int) bool

In identifies and handles IN constraints.

https://sqlite.org/c3ref/vtab_in.html

func (*IndexInfo) RHSValue added in v0.10.3

func (idx *IndexInfo) RHSValue(column int) (Value, error)

RHSValue returns the value of the right-hand operand of a constraint if the right-hand operand is known.

https://sqlite.org/c3ref/vtab_rhs_value.html

type IndexOrderBy added in v0.10.3

type IndexOrderBy struct {
	Column int
	Desc   bool
}

An IndexOrderBy describes virtual table indexing order by information.

https://sqlite.org/c3ref/index_info.html

type IndexScanFlag added in v0.10.3

type IndexScanFlag uint32

IndexScanFlag is a virtual table scan flag.

https://sqlite.org/c3ref/c_index_scan_unique.html

const (
	INDEX_SCAN_UNIQUE IndexScanFlag = 1
)

type LimitCategory added in v0.12.1

type LimitCategory uint32

LimitCategory are the available run-time limit categories.

https://sqlite.org/c3ref/c_limit_attached.html

const (
	LIMIT_LENGTH              LimitCategory = 0
	LIMIT_SQL_LENGTH          LimitCategory = 1
	LIMIT_COLUMN              LimitCategory = 2
	LIMIT_EXPR_DEPTH          LimitCategory = 3
	LIMIT_COMPOUND_SELECT     LimitCategory = 4
	LIMIT_VDBE_OP             LimitCategory = 5
	LIMIT_FUNCTION_ARG        LimitCategory = 6
	LIMIT_ATTACHED            LimitCategory = 7
	LIMIT_LIKE_PATTERN_LENGTH LimitCategory = 8
	LIMIT_VARIABLE_NUMBER     LimitCategory = 9
	LIMIT_TRIGGER_DEPTH       LimitCategory = 10
	LIMIT_WORKER_THREADS      LimitCategory = 11
)

type OpenFlag

type OpenFlag uint32

OpenFlag is a flag for the OpenFlags function.

https://sqlite.org/c3ref/c_open_autoproxy.html

const (
	OPEN_READONLY     OpenFlag = 0x00000001 /* Ok for sqlite3_open_v2() */
	OPEN_READWRITE    OpenFlag = 0x00000002 /* Ok for sqlite3_open_v2() */
	OPEN_CREATE       OpenFlag = 0x00000004 /* Ok for sqlite3_open_v2() */
	OPEN_URI          OpenFlag = 0x00000040 /* Ok for sqlite3_open_v2() */
	OPEN_MEMORY       OpenFlag = 0x00000080 /* Ok for sqlite3_open_v2() */
	OPEN_NOMUTEX      OpenFlag = 0x00008000 /* Ok for sqlite3_open_v2() */
	OPEN_FULLMUTEX    OpenFlag = 0x00010000 /* Ok for sqlite3_open_v2() */
	OPEN_SHAREDCACHE  OpenFlag = 0x00020000 /* Ok for sqlite3_open_v2() */
	OPEN_PRIVATECACHE OpenFlag = 0x00040000 /* Ok for sqlite3_open_v2() */
	OPEN_NOFOLLOW     OpenFlag = 0x01000000 /* Ok for sqlite3_open_v2() */
	OPEN_EXRESCODE    OpenFlag = 0x02000000 /* Extended result codes */
)

type PrepareFlag

type PrepareFlag uint32

PrepareFlag is a flag that can be passed to Conn.PrepareFlags.

https://sqlite.org/c3ref/c_prepare_normalize.html

const (
	PREPARE_PERSISTENT PrepareFlag = 0x01
	PREPARE_NORMALIZE  PrepareFlag = 0x02
	PREPARE_NO_VTAB    PrepareFlag = 0x04
)

type Savepoint added in v0.5.0

type Savepoint struct {
	// contains filtered or unexported fields
}

Savepoint is a marker within a transaction that allows for partial rollback.

https://sqlite.org/lang_savepoint.html

func (Savepoint) Release added in v0.5.0

func (s Savepoint) Release(errp *error)

Release releases the savepoint rolling back any changes if *error points to a non-nil error.

This is meant to be deferred:

func doWork(db *sqlite3.Conn) (err error) {
	savept := db.Savepoint()
	defer savept.Release(&err)

	// ... do work in the transaction
}

func (Savepoint) Rollback added in v0.5.0

func (s Savepoint) Rollback() error

Rollback rolls the transaction back to the savepoint, even if the connection has been interrupted. Rollback does not release the savepoint.

https://sqlite.org/lang_transaction.html

type ScalarFunction added in v0.11.0

type ScalarFunction func(ctx Context, arg ...Value)

ScalarFunction is the type of a scalar SQL function. Implementations must not retain arg.

type Stmt

type Stmt struct {
	// contains filtered or unexported fields
}

Stmt is a prepared statement object.

https://sqlite.org/c3ref/stmt.html

func (*Stmt) BindBlob

func (s *Stmt) BindBlob(param int, value []byte) error

BindBlob binds a []byte to the prepared statement. The leftmost SQL parameter has an index of 1. Binding a nil slice is the same as calling Stmt.BindNull.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindBool

func (s *Stmt) BindBool(param int, value bool) error

BindBool binds a bool to the prepared statement. The leftmost SQL parameter has an index of 1. SQLite does not have a separate boolean storage class. Instead, boolean values are stored as integers 0 (false) and 1 (true).

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindCount added in v0.2.0

func (s *Stmt) BindCount() int

BindCount returns the number of SQL parameters in the prepared statement.

https://sqlite.org/c3ref/bind_parameter_count.html

func (*Stmt) BindFloat

func (s *Stmt) BindFloat(param int, value float64) error

BindFloat binds a float64 to the prepared statement. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindIndex added in v0.2.0

func (s *Stmt) BindIndex(name string) int

BindIndex returns the index of a parameter in the prepared statement given its name.

https://sqlite.org/c3ref/bind_parameter_index.html

func (*Stmt) BindInt

func (s *Stmt) BindInt(param int, value int) error

BindInt binds an int to the prepared statement. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindInt64

func (s *Stmt) BindInt64(param int, value int64) error

BindInt64 binds an int64 to the prepared statement. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindJSON added in v0.10.0

func (s *Stmt) BindJSON(param int, value any) error

BindJSON binds the JSON encoding of value to the prepared statement. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindName added in v0.2.0

func (s *Stmt) BindName(param int) string

BindName returns the name of a parameter in the prepared statement. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_parameter_name.html

func (*Stmt) BindNull

func (s *Stmt) BindNull(param int) error

BindNull binds a NULL to the prepared statement. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindPointer added in v0.10.1

func (s *Stmt) BindPointer(param int, ptr any) error

BindPointer binds a NULL to the prepared statement, just like Stmt.BindNull, but it also associates ptr with that NULL value such that it can be retrieved within an application-defined SQL function using Value.Pointer. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindRawText added in v0.10.3

func (s *Stmt) BindRawText(param int, value []byte) error

BindRawText binds a []byte to the prepared statement as text. The leftmost SQL parameter has an index of 1. Binding a nil slice is the same as calling Stmt.BindNull.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindText

func (s *Stmt) BindText(param int, value string) error

BindText binds a string to the prepared statement. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindTime added in v0.3.0

func (s *Stmt) BindTime(param int, value time.Time, format TimeFormat) error

BindTime binds a time.Time to the prepared statement. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindValue added in v0.11.0

func (s *Stmt) BindValue(param int, value Value) error

BindValue binds a copy of value to the prepared statement. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindZeroBlob added in v0.3.0

func (s *Stmt) BindZeroBlob(param int, n int64) error

BindZeroBlob binds a zero-filled, length n BLOB to the prepared statement. The leftmost SQL parameter has an index of 1.

https://sqlite.org/c3ref/bind_blob.html

func (*Stmt) Busy added in v0.11.0

func (s *Stmt) Busy() bool

Busy determines if a prepared statement has been reset.

https://sqlite.org/c3ref/stmt_busy.html

func (*Stmt) ClearBindings

func (s *Stmt) ClearBindings() error

ClearBindings resets all bindings on the prepared statement.

https://sqlite.org/c3ref/clear_bindings.html

func (*Stmt) Close

func (s *Stmt) Close() error

Close destroys the prepared statement object.

It is safe to close a nil, zero or closed Stmt.

https://sqlite.org/c3ref/finalize.html

func (*Stmt) ColumnBlob

func (s *Stmt) ColumnBlob(col int, buf []byte) []byte

ColumnBlob appends to buf and returns the value of the result column as a []byte. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnBool

func (s *Stmt) ColumnBool(col int) bool

ColumnBool returns the value of the result column as a bool. The leftmost column of the result set has the index 0. SQLite does not have a separate boolean storage class. Instead, boolean values are retrieved as numbers, with 0 converted to false and any other value to true.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnCount added in v0.2.0

func (s *Stmt) ColumnCount() int

ColumnCount returns the number of columns in a result set.

https://sqlite.org/c3ref/column_count.html

func (*Stmt) ColumnDatabaseName added in v0.16.0

func (s *Stmt) ColumnDatabaseName(col int) string

ColumnDatabaseName returns the name of the database that is the origin of a particular result column. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_database_name.html

func (*Stmt) ColumnDeclType added in v0.11.0

func (s *Stmt) ColumnDeclType(col int) string

ColumnDeclType returns the declared datatype of the result column. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_decltype.html

func (*Stmt) ColumnFloat

func (s *Stmt) ColumnFloat(col int) float64

ColumnFloat returns the value of the result column as a float64. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnInt

func (s *Stmt) ColumnInt(col int) int

ColumnInt returns the value of the result column as an int. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnInt64

func (s *Stmt) ColumnInt64(col int) int64

ColumnInt64 returns the value of the result column as an int64. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnJSON added in v0.10.0

func (s *Stmt) ColumnJSON(col int, ptr any) error

ColumnJSON parses the JSON-encoded value of the result column and stores it in the value pointed to by ptr. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnName added in v0.2.0

func (s *Stmt) ColumnName(col int) string

ColumnName returns the name of the result column. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_name.html

func (*Stmt) ColumnOriginName added in v0.16.0

func (s *Stmt) ColumnOriginName(col int) string

ColumnOriginName returns the name of the table column that is the origin of a particular result column. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_database_name.html

func (*Stmt) ColumnRawBlob added in v0.5.2

func (s *Stmt) ColumnRawBlob(col int) []byte

ColumnRawBlob returns the value of the result column as a []byte. The []byte is owned by SQLite and may be invalidated by subsequent calls to Stmt methods. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnRawText added in v0.5.2

func (s *Stmt) ColumnRawText(col int) []byte

ColumnRawText returns the value of the result column as a []byte. The []byte is owned by SQLite and may be invalidated by subsequent calls to Stmt methods. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnTableName added in v0.16.0

func (s *Stmt) ColumnTableName(col int) string

ColumnTableName returns the name of the table that is the origin of a particular result column. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_database_name.html

func (*Stmt) ColumnText

func (s *Stmt) ColumnText(col int) string

ColumnText returns the value of the result column as a string. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnTime added in v0.3.0

func (s *Stmt) ColumnTime(col int, format TimeFormat) time.Time

ColumnTime returns the value of the result column as a time.Time. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnType

func (s *Stmt) ColumnType(col int) Datatype

ColumnType returns the initial Datatype of the result column. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnValue added in v0.11.0

func (s *Stmt) ColumnValue(col int) Value

ColumnValue returns the unprotected value of the result column. The leftmost column of the result set has the index 0.

https://sqlite.org/c3ref/column_blob.html

func (*Stmt) Columns added in v0.12.0

func (s *Stmt) Columns(dest ...any) error

Columns populates result columns into the provided slice. The slice must have Stmt.ColumnCount length.

INTEGER columns will be retrieved as int64 values, FLOAT as float64, NULL as nil, TEXT as string, and BLOB as []byte. Any []byte are owned by SQLite and may be invalidated by subsequent calls to Stmt methods.

func (*Stmt) Conn added in v0.11.0

func (s *Stmt) Conn() *Conn

Conn returns the database connection to which the prepared statement belongs.

https://sqlite.org/c3ref/db_handle.html

func (*Stmt) DataCount added in v0.19.0

func (s *Stmt) DataCount() int

DataCount resets the number of columns in a result set.

https://sqlite.org/c3ref/data_count.html

func (*Stmt) Err

func (s *Stmt) Err() error

Err gets the last error occurred during Stmt.Step. Err returns nil after Stmt.Reset is called.

https://sqlite.org/c3ref/step.html

func (*Stmt) Exec

func (s *Stmt) Exec() error

Exec is a convenience function that repeatedly calls Stmt.Step until it returns false, then calls Stmt.Reset to reset the statement and get any error that occurred.

func (*Stmt) ExpandedSQL added in v0.18.0

func (s *Stmt) ExpandedSQL() string

ExpandedSQL returns the SQL text of the prepared statement with bound parameters expanded.

https://sqlite.org/c3ref/expanded_sql.html

func (*Stmt) ReadOnly added in v0.11.0

func (s *Stmt) ReadOnly() bool

ReadOnly returns true if and only if the statement makes no direct changes to the content of the database file.

https://sqlite.org/c3ref/stmt_readonly.html

func (*Stmt) Reset

func (s *Stmt) Reset() error

Reset resets the prepared statement object.

https://sqlite.org/c3ref/reset.html

func (*Stmt) SQL added in v0.18.0

func (s *Stmt) SQL() string

SQL returns the SQL text used to create the prepared statement.

https://sqlite.org/c3ref/expanded_sql.html

func (*Stmt) Status added in v0.11.0

func (s *Stmt) Status(op StmtStatus, reset bool) int

Status monitors the performance characteristics of prepared statements.

https://sqlite.org/c3ref/stmt_status.html

func (*Stmt) Step

func (s *Stmt) Step() bool

Step evaluates the SQL statement. If the SQL statement being executed returns any data, then true is returned each time a new row of data is ready for processing by the caller. The values may be accessed using the Column access functions. Step is called again to retrieve the next row of data. If an error has occurred, Step returns false; call Stmt.Err or Stmt.Reset to get the error.

https://sqlite.org/c3ref/step.html

type StmtStatus added in v0.11.0

type StmtStatus uint32

StmtStatus name counter values associated with the Stmt.Status method.

https://sqlite.org/c3ref/c_stmtstatus_counter.html

const (
	STMTSTATUS_FULLSCAN_STEP StmtStatus = 1
	STMTSTATUS_SORT          StmtStatus = 2
	STMTSTATUS_AUTOINDEX     StmtStatus = 3
	STMTSTATUS_VM_STEP       StmtStatus = 4
	STMTSTATUS_REPREPARE     StmtStatus = 5
	STMTSTATUS_RUN           StmtStatus = 6
	STMTSTATUS_FILTER_MISS   StmtStatus = 7
	STMTSTATUS_FILTER_HIT    StmtStatus = 8
	STMTSTATUS_MEMUSED       StmtStatus = 99
)

type TimeFormat added in v0.3.0

type TimeFormat string

TimeFormat specifies how to encode/decode time values.

See the documentation for the TimeFormatDefault constant for formats recognized by SQLite.

https://sqlite.org/lang_datefunc.html

func (TimeFormat) Decode added in v0.3.0

func (f TimeFormat) Decode(v any) (time.Time, error)

Decode decodes a time value using this format.

The time value can be a string, an int64, or a float64.

Formats TimeFormat8 through TimeFormat10 (and TimeFormat8TZ through TimeFormat10TZ) assume a date of 2000-01-01.

The timezone indicator and fractional seconds are always optional for formats TimeFormat2 through TimeFormat10 (and TimeFormat2TZ through TimeFormat10TZ).

TimeFormatAuto implements (and extends) the SQLite auto modifier. Julian day numbers are safe to use for historical dates, from 4712BC through 9999AD. Unix timestamps (expressed in seconds, milliseconds, microseconds, or nanoseconds) are safe to use for current events, from at least 1980 through at least 2260. Unix timestamps before 1980 and after 9999 may be misinterpreted as julian day numbers, or have the wrong time unit.

https://sqlite.org/lang_datefunc.html

func (TimeFormat) Encode added in v0.3.0

func (f TimeFormat) Encode(t time.Time) any

Encode encodes a time value using this format.

TimeFormatDefault and TimeFormatAuto encode using time.RFC3339Nano, with nanosecond accuracy, and preserving any timezone offset.

This is the format used by the database/sql driver: database/sql.Row.Scan will decode as time.Time values encoded with time.RFC3339Nano.

Time values encoded with time.RFC3339Nano cannot be sorted as strings to produce a time-ordered sequence.

Assuming that the time zones of the time values are the same (e.g., all in UTC), and expressed using the same string (e.g., all "Z" or all "+00:00"), use the TIME collating sequence to produce a time-ordered sequence.

Otherwise, use TimeFormat7 for time-ordered encoding.

Formats TimeFormat1 through TimeFormat10 convert time values to UTC before encoding.

Returns a string for the text formats, a float64 for TimeFormatJulianDay and TimeFormatUnixFrac, or an int64 for the other numeric formats.

https://sqlite.org/lang_datefunc.html

func (TimeFormat) Scanner added in v0.10.0

func (f TimeFormat) Scanner(dest *time.Time) interface{ Scan(any) error }

Scanner returns a database/sql.Scanner that can be used as an argument to database/sql.Row.Scan and similar methods to decode a time value into dest using this format.

type TraceEvent added in v0.18.0

type TraceEvent uint32

TraceEvent identify classes of events that can be monitored with Conn.Trace.

https://sqlite.org/c3ref/c_trace.html

const (
	TRACE_STMT    TraceEvent = 0x01
	TRACE_PROFILE TraceEvent = 0x02
	TRACE_ROW     TraceEvent = 0x04
	TRACE_CLOSE   TraceEvent = 0x08
)

type Txn added in v0.12.1

type Txn struct {
	// contains filtered or unexported fields
}

Txn is an in-progress database transaction.

https://sqlite.org/lang_transaction.html

func (Txn) Commit added in v0.12.1

func (tx Txn) Commit() error

Commit commits the transaction.

https://sqlite.org/lang_transaction.html

func (Txn) End added in v0.12.1

func (tx Txn) End(errp *error)

End calls either Txn.Commit or Txn.Rollback depending on whether *error points to a nil or non-nil error.

This is meant to be deferred:

func doWork(db *sqlite3.Conn) (err error) {
	tx := db.Begin()
	defer tx.End(&err)

	// ... do work in the transaction
}

https://sqlite.org/lang_transaction.html

func (Txn) Rollback added in v0.12.1

func (tx Txn) Rollback() error

Rollback rolls back the transaction, even if the connection has been interrupted.

https://sqlite.org/lang_transaction.html

type TxnState added in v0.12.1

type TxnState uint32

TxnState are the allowed return values from Conn.TxnState.

https://sqlite.org/c3ref/c_txn_none.html

const (
	TXN_NONE  TxnState = 0
	TXN_READ  TxnState = 1
	TXN_WRITE TxnState = 2
)

type VTab added in v0.10.3

A VTab describes a particular instance of the virtual table. A VTab may optionally implement io.Closer to free resources.

https://sqlite.org/c3ref/vtab.html

type VTabChecker added in v0.10.3

type VTabChecker interface {
	VTab
	// https://sqlite.org/vtab.html#xintegrity
	Integrity(schema, table string, flags int) error
}

A VTabChecker allows a virtual table to report errors to the PRAGMA integrity_check and PRAGMA quick_check commands.

Integrity should return an error if it finds problems in the content of the virtual table, but should avoid returning a (wrapped) Error, ErrorCode or ExtendedErrorCode, as those indicate the Integrity method itself encountered problems while trying to evaluate the virtual table content.

type VTabConfigOption added in v0.12.0

type VTabConfigOption uint8

VTabConfigOption is a virtual table configuration option.

https://sqlite.org/c3ref/c_vtab_constraint_support.html

const (
	VTAB_CONSTRAINT_SUPPORT VTabConfigOption = 1
	VTAB_INNOCUOUS          VTabConfigOption = 2
	VTAB_DIRECTONLY         VTabConfigOption = 3
	VTAB_USES_ALL_SCHEMAS   VTabConfigOption = 4
)

type VTabConflictMode added in v0.12.0

type VTabConflictMode uint8

VTabConflictMode is a virtual table conflict resolution mode.

https://sqlite.org/c3ref/c_fail.html

const (
	VTAB_ROLLBACK VTabConflictMode = 1
	VTAB_IGNORE   VTabConflictMode = 2
	VTAB_FAIL     VTabConflictMode = 3
	VTAB_ABORT    VTabConflictMode = 4
	VTAB_REPLACE  VTabConflictMode = 5
)

type VTabConstructor added in v0.10.3

type VTabConstructor[T VTab] func(db *Conn, module, schema, table string, arg ...string) (T, error)

VTabConstructor is a virtual table constructor function.

type VTabCursor added in v0.10.3

A VTabCursor describes cursors that point into the virtual table and are used to loop through the virtual table. A VTabCursor may optionally implement io.Closer to free resources.

http://sqlite.org/c3ref/vtab_cursor.html

type VTabDestroyer added in v0.10.3

type VTabDestroyer interface {
	VTab
	// https://sqlite.org/vtab.html#sqlite3_module.xDestroy
	Destroy() error
}

A VTabDestroyer allows a virtual table to drop persistent state.

type VTabOverloader added in v0.10.3

type VTabOverloader interface {
	VTab
	// https://sqlite.org/vtab.html#xfindfunction
	FindFunction(arg int, name string) (ScalarFunction, IndexConstraintOp)
}

A VTabOverloader allows a virtual table to overload SQL functions.

type VTabRenamer added in v0.10.3

type VTabRenamer interface {
	VTab
	// https://sqlite.org/vtab.html#xrename
	Rename(new string) error
}

A VTabRenamer allows a virtual table to be renamed.

type VTabSavepointer added in v0.10.3

type VTabSavepointer interface {
	VTabTxn
	Savepoint(id int) error
	Release(id int) error
	RollbackTo(id int) error
}

A VTabSavepointer allows a virtual table to implement nested transactions.

https://sqlite.org/vtab.html#xsavepoint

type VTabShadowTabler added in v0.16.3

type VTabShadowTabler interface {
	VTab
	// https://sqlite.org/vtab.html#the_xshadowname_method
	ShadowTables()
}

A VTabShadowTabler allows a virtual table to protect the content of shadow tables from being corrupted by hostile SQL.

Implementing this interface signals that a virtual table named "mumble" reserves all table names starting with "mumble_".

type VTabTxn added in v0.12.2

A VTabTxn allows a virtual table to implement transactions with two-phase commit.

Anything that is required as part of a commit that may fail should be performed in the Sync() callback. Current versions of SQLite ignore any errors returned by Commit() and Rollback().

type VTabUpdater added in v0.10.3

type VTabUpdater interface {
	VTab
	// https://sqlite.org/vtab.html#xupdate
	Update(arg ...Value) (rowid int64, err error)
}

A VTabUpdater allows a virtual table to be updated.

type Value added in v0.8.2

type Value struct {
	// contains filtered or unexported fields
}

Value is any value that can be stored in a database table.

https://sqlite.org/c3ref/value.html

func (Value) Blob added in v0.8.2

func (v Value) Blob(buf []byte) []byte

Blob appends to buf and returns the value as a []byte.

https://sqlite.org/c3ref/value_blob.html

func (Value) Bool added in v0.8.2

func (v Value) Bool() bool

Bool returns the value as a bool. SQLite does not have a separate boolean storage class. Instead, boolean values are retrieved as numbers, with 0 converted to false and any other value to true.

https://sqlite.org/c3ref/value_blob.html

func (*Value) Close added in v0.11.0

func (dup *Value) Close() error

Close frees an SQL value previously obtained by Value.Dup.

https://sqlite.org/c3ref/value_dup.html

func (Value) Dup added in v0.11.0

func (v Value) Dup() *Value

Dup makes a copy of the SQL value and returns a pointer to that copy.

https://sqlite.org/c3ref/value_dup.html

func (Value) Float added in v0.8.2

func (v Value) Float() float64

Float returns the value as a float64.

https://sqlite.org/c3ref/value_blob.html

func (Value) FromBind added in v0.18.0

func (v Value) FromBind() bool

FromBind returns true if value originated from a bound parameter.

https://sqlite.org/c3ref/value_blob.html

func (Value) InFirst added in v0.12.0

func (v Value) InFirst() (Value, error)

InFirst returns the first element on the right-hand side of an IN constraint.

https://sqlite.org/c3ref/vtab_in_first.html

func (Value) InNext added in v0.12.0

func (v Value) InNext() (Value, error)

InNext returns the next element on the right-hand side of an IN constraint.

https://sqlite.org/c3ref/vtab_in_first.html

func (Value) Int added in v0.8.2

func (v Value) Int() int

Int returns the value as an int.

https://sqlite.org/c3ref/value_blob.html

func (Value) Int64 added in v0.8.2

func (v Value) Int64() int64

Int64 returns the value as an int64.

https://sqlite.org/c3ref/value_blob.html

func (Value) JSON added in v0.10.0

func (v Value) JSON(ptr any) error

JSON parses a JSON-encoded value and stores the result in the value pointed to by ptr.

func (Value) NoChange added in v0.12.0

func (v Value) NoChange() bool

NoChange returns true if and only if the value is unchanged in a virtual table update operatiom.

https://sqlite.org/c3ref/value_blob.html

func (Value) NumericType added in v0.12.0

func (v Value) NumericType() Datatype

Type returns the numeric datatype of the value.

https://sqlite.org/c3ref/value_blob.html

func (Value) Pointer added in v0.10.1

func (v Value) Pointer() any

Pointer gets the pointer associated with this value, or nil if it has no associated pointer.

func (Value) RawBlob added in v0.8.2

func (v Value) RawBlob() []byte

RawBlob returns the value as a []byte. The []byte is owned by SQLite and may be invalidated by subsequent calls to Value methods.

https://sqlite.org/c3ref/value_blob.html

func (Value) RawText added in v0.8.2

func (v Value) RawText() []byte

RawText returns the value as a []byte. The []byte is owned by SQLite and may be invalidated by subsequent calls to Value methods.

https://sqlite.org/c3ref/value_blob.html

func (Value) Text added in v0.8.2

func (v Value) Text() string

Text returns the value as a string.

https://sqlite.org/c3ref/value_blob.html

func (Value) Time added in v0.8.2

func (v Value) Time(format TimeFormat) time.Time

Time returns the value as a time.Time.

https://sqlite.org/c3ref/value_blob.html

func (Value) Type added in v0.8.2

func (v Value) Type() Datatype

Type returns the initial datatype of the value.

https://sqlite.org/c3ref/value_blob.html

type WindowFunction added in v0.8.2

type WindowFunction interface {
	AggregateFunction

	// Inverse is invoked to remove the oldest presently aggregated result of Step from the current window.
	// The function arguments, if any, are those passed to Step for the row being removed.
	// Implementations must not retain arg.
	Inverse(ctx Context, arg ...Value)
}

WindowFunction is the interface an aggregate window function should implement.

https://sqlite.org/windowfunctions.html

type ZeroBlob added in v0.3.0

type ZeroBlob int64

ZeroBlob represents a zero-filled, length n BLOB that can be used as an argument to database/sql.DB.Exec and similar methods.

Directories

Path Synopsis
Package driver provides a database/sql driver for SQLite.
Package driver provides a database/sql driver for SQLite.
Package embed embeds SQLite into your application.
Package embed embeds SQLite into your application.
bcw2 Module
ext
array
Package array provides the array table-valued SQL function.
Package array provides the array table-valued SQL function.
blobio
Package blobio provides an SQL interface to incremental BLOB I/O.
Package blobio provides an SQL interface to incremental BLOB I/O.
bloom
Package bloom provides a Bloom filter virtual table.
Package bloom provides a Bloom filter virtual table.
closure
Package closure provides a transitive closure virtual table.
Package closure provides a transitive closure virtual table.
csv
Package csv provides a CSV virtual table.
Package csv provides a CSV virtual table.
fileio
Package fileio provides SQL functions to read, write and list files.
Package fileio provides SQL functions to read, write and list files.
hash
Package hash provides cryptographic hash functions.
Package hash provides cryptographic hash functions.
lines
Package lines provides a virtual table to read data line-by-line.
Package lines provides a virtual table to read data line-by-line.
pivot
Package pivot implements a pivot virtual table.
Package pivot implements a pivot virtual table.
regexp
Package regexp provides additional regular expression functions.
Package regexp provides additional regular expression functions.
statement
Package statement defines table-valued functions using SQL.
Package statement defines table-valued functions using SQL.
stats
Package stats provides aggregate functions for statistics.
Package stats provides aggregate functions for statistics.
unicode
Package unicode provides an alternative to the SQLite ICU extension.
Package unicode provides an alternative to the SQLite ICU extension.
uuid
Package uuid provides functions to generate RFC 4122 UUIDs.
Package uuid provides functions to generate RFC 4122 UUIDs.
zorder
Package zorder provides functions for z-order transformations.
Package zorder provides functions for z-order transformations.
gormlite module
internal
util
fsutil
Package fsutil implements filesystem utilities.
Package fsutil implements filesystem utilities.
ioutil
Package ioutil implements I/O utilities.
Package ioutil implements I/O utilities.
osutil
Package osutil implements operating system utilities.
Package osutil implements operating system utilities.
sql3util
Package sql3util implements SQLite utilities.
Package sql3util implements SQLite utilities.
vfsutil
Package vfsutil implements virtual filesystem utilities.
Package vfsutil implements virtual filesystem utilities.
vfs
Package vfs wraps the C SQLite VFS API.
Package vfs wraps the C SQLite VFS API.
adiantum
Package adiantum wraps an SQLite VFS to offer encryption at rest.
Package adiantum wraps an SQLite VFS to offer encryption at rest.
memdb
Package memdb implements the "memdb" SQLite VFS.
Package memdb implements the "memdb" SQLite VFS.
readervfs
Package readervfs implements an SQLite VFS for immutable databases.
Package readervfs implements an SQLite VFS for immutable databases.
xts
Package xts wraps an SQLite VFS to offer encryption at rest.
Package xts wraps an SQLite VFS to offer encryption at rest.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL