sqlite

package
v0.0.0-...-1e81722 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

DB represents an SQLite database.

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

BeginTx starts a transaction using the read-write database connection and returns a Tx.

func (*DB) Open

func (db *DB) Open() (err error)

Open opens reading and writing database connections and executes any database migrations.

func (*DB) QueryContext

func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

QueryContext executes a query that returns rows using the read-only database connection.

func (*DB) QueryRowContext

func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row

QueryRowContext executes a query that is expected to return at most one row using the read-only database connection.

type MainDB

type MainDB struct {
	DB
}

MainDB represents the SQLite database where permanent data is stored.

func NewMainDB

func NewMainDB(path string, logger *slog.Logger) *MainDB

NewMainDB returns a new instance of MainDB. If the given path is an empty string, an in-memory database is used.

type NullTime

type NullTime time.Time

NullTime represents a wrapper around time.Time, providing support for storing and reading time values formatted using time.RFC3339 to and from SQLite databases. NULL values are converted to zero-value times.

func (*NullTime) Scan

func (n *NullTime) Scan(src any) error

Scan implements the sql.Scanner interface.

func (*NullTime) Value

func (n *NullTime) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Tx

type Tx struct {
	*sql.Tx
	Now time.Time
}

Tx provides a sql.Tx and a transaction start timestamp.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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