sqlite

package module
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 14 Imported by: 0

README

sqlite

import "github.com/kitsunium/sdk/framework/connectors/sqlite"

Package sqlite — the driver, linked on every GOOS modernc.org/sqlite has a port to.

Package sqlite — no driver on dragonfly, illumos and solaris, which modernc.org/sqlite has no port to.

Package sqlite is kit's SQLite engine (ADR 0004): the one module a kit product imports to keep a database in a SQLite file, and the only code of the product that imports a SQLite driver — modernc.org/sqlite, "a CGo-free port of the C SQLite3 library", so a kit product stays one static binary (CGO_ENABLED=0). The product's main declares the database with it:

import "github.com/kitsunium/sdk/framework/connectors/sqlite"

var App = app.NewApp("vigie", intake.Service, audit.Service).With(
	app.Database("archive", sqlite.Engine(), app.Keeps(audit.Service)),
)

Its URL, in the variable <APP>_<NAME>_URL, is the file's path — or a file: URI, with the driver's parameters —; without one, kit keeps the database in <data>/<name>.sqlite. The engine opens the file in WAL mode with a busy timeout, and its transactions take the write lock when they begin (_txlock=immediate), so two writers queue rather than fail; a parameter the URL writes itself wins. Under WAL it syncs at the checkpoint rather than at every commit (_synchronous=NORMAL): a power cut may lose the last commits, never the database — write ?_synchronous=FULL for every commit on disk. It caps the WAL a burst grew at 64 MiB after its checkpoint (_pragma=journal_size_limit(67108864)), unless the URL writes a _pragma of its own. It is an app.LockWaiter: kit gives it a busy timeout under <name>-timeout, T − max(250ms, T/10), and refuses at start a T under 500ms or a URL whose own busy timeout reaches T.

On dragonfly, illumos and solaris, which modernc.org/sqlite does not port to, the module builds and Open refuses with proc.UnsupportedPlatform.

Its migrations — kit's own, which make the tables of the stores it keeps, then the product's and the modules' — run under the database file's own write lock, one transaction per run (the SDK's ADR 0140).

app.Keeps(app.Privacy) on the file keeps kit's legal holds and privacy journal there, in the product's transactions, and kit's data keys in the data directory: a data key is written apart from every transaction, and the file's one writer may be held by the transaction of the very write that needs the key.

Index

Constants

const CodeURLMalformed errs.Code = 266753

CodeURLMalformed identifies a URL the driver cannot read (ADR 0147: layer 4, one PP per connector).

Code 0.4.18.1

func Engine

func Engine() app.Engine

Engine is the SQLite engine, for app.Database.

Generated from docs/api by tools/genindex.

Documentation

Overview

Package sqlite — the driver, linked on every GOOS modernc.org/sqlite has a port to.

Package sqlite — no driver on dragonfly, illumos and solaris, which modernc.org/sqlite has no port to.

Package sqlite is kit's SQLite engine (ADR 0004): the one module a kit product imports to keep a database in a SQLite file, and the only code of the product that imports a SQLite driver — modernc.org/sqlite, "a CGo-free port of the C SQLite3 library", so a kit product stays one static binary (CGO_ENABLED=0). The product's main declares the database with it:

import "github.com/kitsunium/sdk/framework/connectors/sqlite"

var App = app.NewApp("vigie", intake.Service, audit.Service).With(
	app.Database("archive", sqlite.Engine(), app.Keeps(audit.Service)),
)

Its URL, in the variable <APP>_<NAME>_URL, is the file's path — or a file: URI, with the driver's parameters —; without one, kit keeps the database in <data>/<name>.sqlite. The engine opens the file in WAL mode with a busy timeout, and its transactions take the write lock when they begin (_txlock=immediate), so two writers queue rather than fail; a parameter the URL writes itself wins. Under WAL it syncs at the checkpoint rather than at every commit (_synchronous=NORMAL): a power cut may lose the last commits, never the database — write ?_synchronous=FULL for every commit on disk. It caps the WAL a burst grew at 64 MiB after its checkpoint (_pragma=journal_size_limit(67108864)), unless the URL writes a _pragma of its own. It is an app.LockWaiter: kit gives it a busy timeout under <name>-timeout, T − max(250ms, T/10), and refuses at start a T under 500ms or a URL whose own busy timeout reaches T.

On dragonfly, illumos and solaris, which modernc.org/sqlite does not port to, the module builds and Open refuses with proc.UnsupportedPlatform.

Its migrations — kit's own, which make the tables of the stores it keeps, then the product's and the modules' — run under the database file's own write lock, one transaction per run (the SDK's ADR 0140).

app.Keeps(app.Privacy) on the file keeps kit's legal holds and privacy journal there, in the product's transactions, and kit's data keys in the data directory: a data key is written apart from every transaction, and the file's one writer may be held by the transaction of the very write that needs the key.

Index

Constants

View Source
const (
	// CodeURLMalformed identifies a URL the driver cannot read (ADR 0147: layer 4,
	// one PP per connector).
	CodeURLMalformed errs.Code = 0x00_04_12_01 // 0.4.18.1
)

Variables

This section is empty.

Functions

func Engine

func Engine() app.Engine

Engine is the SQLite engine, for app.Database.

Types

This section is empty.

Jump to

Keyboard shortcuts

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