sqlite

package
v0.9.1 Latest Latest
Warning

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

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

Documentation

Overview

Package sqlite implements MDM storage with the pure Go modernc.org/sqlite driver.

Design

The dialect supplies SQL syntax and embedded migrations to sqlcommon. Connections use WAL, foreign keys, a busy timeout and immediate write transactions to coordinate writers. Driver uniqueness failures map to storage.ErrConflict.

The backend requires no external service and runs the common storage contracts, sealing/rotation checks and cross-backend migration tests. SQLite persistence still requires protected files, keys and backups for production use.

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