sqliteutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountRows

func CountRows(dbPath string, journalOff bool, query string) (int, error)

CountRows runs a scalar count query (e.g. SELECT COUNT(*) FROM ...) and returns the integer result. Unlike QuerySQLite (which swallows per-row scan errors), CountRows uses QueryRow for fail-fast behavior on scan failures.

func QueryRows

func QueryRows[T any](dbPath string, journalOff bool, query string, scanRow func(*sql.Rows) (T, error)) ([]T, error)

QueryRows is a generic helper (Go 1.18+) that wraps QuerySQLite and collects results into a typed slice. Each extract method only needs to provide the scan function that converts one database row into a typed value.

Rows that fail to scan are skipped (logged at debug level by QuerySQLite).

func QuerySQLite

func QuerySQLite(dbPath string, journalOff bool, query string, scanFn func(*sql.Rows) error) error

QuerySQLite opens a SQLite database, optionally disables journal mode (required for Firefox databases), runs the query, and calls scanFn for each row.

It validates the database file exists before opening to prevent sql.Open from silently creating an empty database.

scanFn should return nil to continue iteration, or an error to skip the current row (the error is logged at debug level and iteration continues).

Types

This section is empty.

Jump to

Keyboard shortcuts

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