sqlite

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqlite provides a standardized SQLite connection opener and a scoped, version-tracked schema migration runner built on modernc.org/sqlite.

Connection Pragmas

Open configures every connection in the *database/sql.DB pool with production SQLite pragmas via DSN parameters:

  • `busy_timeout = 5000` (5 seconds) to prevent transient `SQLITE_BUSY` errors.
  • `journal_mode = WAL` for concurrent readers and writers.
  • `foreign_keys = ON` so `ON DELETE CASCADE` and referential integrity are enforced across all pooled connections.
  • `synchronous = NORMAL` for safe, high-throughput WAL durability.

Scoped Schema Migrations

Migrate maintains an isolated `<scope>_migrations` version table per subsystem (for example, `session_migrations`), allowing multiple internal packages to manage their own ordered DDL migration slices independently on a shared *database/sql.DB handle. Each migration step is applied atomically inside a transaction alongside its version record.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPath  = errors.New("sqlite: database path must not be empty")
	ErrNilDB        = errors.New("sqlite: database connection must not be nil")
	ErrInvalidScope = errors.New("sqlite: migration scope must be a non-empty alphanumeric/underscore identifier")
)

Sentinel errors returned by the sqlite package.

Functions

func Migrate

func Migrate(ctx context.Context, db *sql.DB, scope string, migrations []string) error

Migrate executes any unapplied SQL migrations in migrations for the given subsystem scope, tracking applied indices in `<scope>_migrations`.

func Open

func Open(ctx context.Context, path string) (*sql.DB, error)

Open opens a SQLite database at path with standard production pragmas (`busy_timeout=5000`, `journal_mode=WAL`, `foreign_keys=ON`, `synchronous=NORMAL`) applied to all connections in the pool.

Types

This section is empty.

Jump to

Keyboard shortcuts

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