sqlite

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sqlite opens the composite SQL store on SQLite: the pool of the platform/sql/sqlite driver, migrated and wrapped in the composite store of app/adapters/sql.

Role

app, adapter layer (SQL on SQLite): opens the composite on one driver with the options and error texts it had before the composite moved under app. app's store opener calls it for the sqlite database type; the tests of the modules reach it only through app/storetest's OpenSQLite. It imports app/adapters/sql and the SQLite driver.

Inputs

  • Open: the path of the database file, or the driver's Memory path, and Options: the composite store's Options and the driver's busy timeout.

Outputs

  • Open: the composite store over the database, created if it does not exist, migrated unless Options.SkipMigrate.

Invariants

  • The driver's errors, ErrPathRequired among them, are returned as they are, and the composite's open errors behind "sqlite: ", so the texts that operators see and the wrapcheck exception for the driver's OpenDB stay as they were.
  • On any failure the pool is closed and no store is returned.

References

Status

Implemented P2 (pull request 3). Moved here in P9d: the pool comes from the platform/sql/sqlite driver (issue 995), and the package moved under app (issue 1098).

Testing

  • sqlite_test.go: TestAccContractFile and TestAccContractMemory run the composite contract of app/storetest on a file and in memory; TestAccMigrationsUpDownUp, TestAccLegacyHistoryRefused, TestAccOpenErrors, TestAccKeyRotation, TestAccRemoteCachePersistence, TestAccRepositoryHeaderSecrets and TestAccRepositoryHeaderMigration run its composite suites.
  • schema_test.go: TestAccSchemaGolden compares the migrated schema with testdata/schema.golden.
  • replay_test.go: TestAccReplayProcessCrash kills a child process, TestAccReplayCrashHelper, after its write and before the write's replay receipt commits, and checks that both roll back; TestAccKeyedReplayProcessCrash, with its child TestAccKeyedReplayCrashHelper, does the same under the shared replay of keyed operations, inside its effect.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

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

Open opens the composite store on the SQLite database at path, creating it if needed: the driver's pool with o's busy timeout, which appsql.Open pings, migrates unless o.SkipMigrate, wraps in the SQL store and closes on failure. The driver's Memory path opens a private in-memory database. The driver's errors, ErrPathRequired among them, are returned as they are, and appsql.Open's behind "sqlite: ".

Types

type Options

type Options struct {
	appsql.Options
	// BusyTimeout bounds lock waits; 10s when zero.
	BusyTimeout time.Duration
}

Options configures Open: the store's options, and the driver's, which Open passes on.

Jump to

Keyboard shortcuts

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