sqliteutil

package
v1.138.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckpointAndClose added in v1.51.0

func CheckpointAndClose(ctx context.Context, db *sql.DB) error

CheckpointAndClose runs a final WAL checkpoint and closes the database. The TRUNCATE checkpoint folds the -wal file back into the main database so it isn't left behind on disk after shutdown. A checkpoint failure is logged but does not prevent the close.

func CloseDB added in v1.137.0

func CloseDB(db *sql.DB) error

CloseDB closes db and waits until every connection has actually been released. sql.DB.Close only closes idle connections: one checked out by an in-flight statement is closed when that statement returns, after Close has already come back. On Windows the database file cannot be deleted while such a connection still holds it, so callers that remove the directory right after closing (tests with t.TempDir, recovery paths) need the handle gone before Close returns. Waiting is bounded so a wedged statement cannot hang shutdown.

func DiagnoseDBOpenError

func DiagnoseDBOpenError(path string, originalErr error) error

DiagnoseDBOpenError provides a more helpful error message when SQLite fails to open/create a database file.

func IsCantOpenError

func IsCantOpenError(err error) bool

IsCantOpenError checks if the error is a SQLite CANTOPEN error (code 14).

func IsTransientError added in v1.102.0

func IsTransientError(err error) bool

IsTransientError reports whether err is a temporary condition that a retry (not a schema fix) would resolve: a canceled/expired context, or a SQLite BUSY/LOCKED error from a concurrent writer. The primary result code is compared after masking off extended-code bits (e.g. SQLITE_BUSY_SNAPSHOT).

func OpenDB

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

OpenDB opens a SQLite database with recommended pragmas for concurrency and foreign key support. It configures the connection pool for serialized writes (MaxOpenConns=1).

Types

This section is empty.

Jump to

Keyboard shortcuts

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