database

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Overview

Package database provides shared SQLite helpers for schema migration and connection management. All stores that open or migrate SQLite databases should use these helpers for consistency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddColumn

func AddColumn(db *sql.DB, table, column, typedef string) error

AddColumn idempotently adds a column to an existing table. If the column already exists the call is a no-op. The typedef parameter is the SQL type and optional constraints, for example "TEXT" or "INTEGER DEFAULT 0".

func HasColumn

func HasColumn(db *sql.DB, table, column string) bool

HasColumn reports whether the given table contains a column with the specified name. It uses a lightweight SELECT probe that avoids scanning any rows. Identifiers are left unquoted because SQLite treats double-quoted unknown identifiers as string literals, which would make the probe always succeed.

func Open

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

Open opens a SQLite database at the given path with standard production settings: WAL journal mode and a 5-second busy timeout. Callers must ensure the github.com/mattn/go-sqlite3 driver is registered (typically via a blank import in the binary's main package or test file).

func ParseTimestamp

func ParseTimestamp(s string) (time.Time, error)

ParseTimestamp parses a timestamp string from SQLite, accepting multiple common formats. This provides read-side defense against format mismatches — the write side should continue using RFC3339.

Types

This section is empty.

Jump to

Keyboard shortcuts

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