sqlite

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package sqlite is the SQLite storage backend on modernc.org/sqlite (pure Go, no cgo).

Why

Phase 4 of the plan of record promises the same storage contract on four backends, and SQLite is the one a single-binary deployment and the end-to-end suite run without a server (decision record 0012). This package supplies the Dialect that sqlcommon needs, the DSN builder, and the connection settings that make SQLite safe under concurrent writers: WAL journal, foreign keys, a busy timeout, and immediate write transactions so writers queue instead of failing. IsUniqueViolation maps driver errors to storage.ErrConflict. Because it needs no external service, the sealing, rewrap, and cross-backend migration tests for the whole SQL layer run here.

All statement logic, migrations, and sealing live in sqlcommon; the contract is proven by storagetest.

References

Index

Constants

This section is empty.

Variables

View Source
var Dialect = sqlcommon.Dialect{
	Name:              "sqlite",
	Upsert:            sqlcommon.UpsertOnConflict,
	Migrations:        sqlcommon.MustSub(migrationFS, "migrations"),
	InsertIgnore:      sqlcommon.InsertIgnoreOnConflict,
	IsUniqueViolation: IsUniqueViolation,
}

Dialect is the SQLite dialect.

View Source
var ErrPathRequired = errors.New("sqlite: path is required")

ErrPathRequired is returned by Open for an empty path.

Functions

func DSN

func DSN(path string, o Options) string

DSN renders the driver connection string for a database file with the pragmas the backend relies on.

func IsUniqueViolation

func IsUniqueViolation(err error) bool

IsUniqueViolation reports whether err is a SQLite unique or primary key constraint failure.

Types

type Options

type Options struct {
	// BusyTimeout waits for a locked database; default 10s.
	BusyTimeout time.Duration
	// Migrate applies pending migrations on open; default true unless
	// SkipMigrate is set.
	SkipMigrate bool
	// Keyring seals the secret columns (decision record 0013); nil keeps
	// them in plaintext.
	Keyring *crypt.Keyring
}

Options tune Open.

type Store

type Store struct{ *sqlcommon.Store }

Store is the SQLite backend.

func Open

func Open(ctx context.Context, path string, o Options) (*Store, error)

Open opens (creating if needed) the database file and migrates it.

Jump to

Keyboard shortcuts

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