sqliteexec

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const EnvBackend = "HERDR_SQLITE_BACKEND"

EnvBackend is the relay env var that selects the SQLite query backend.

Variables

View Source
var (
	// ErrOutputLimit means the query result exceeded the caller max byte budget.
	ErrOutputLimit = errors.New("sqlite query output limit exceeded")
	// ErrUnavailable means no usable backend could be constructed.
	ErrUnavailable = errors.New("sqlite query backend unavailable")
)

Functions

func NormalizeJSONArray

func NormalizeJSONArray(raw []byte) []byte

NormalizeJSONArray turns empty CLI stdout into a JSON array so callers can always json.Unmarshal into a slice.

Types

type Backend

type Backend string

Backend selects how conversation readers execute SQL against agent SQLite files.

const (
	BackendAuto   Backend = "auto"
	BackendNative Backend = "native"
	BackendCLI    Backend = "cli"
)

func ParseBackend

func ParseBackend(value string) Backend

ParseBackend normalizes env / config values. Empty means auto.

type Executor

type Executor interface {
	// Ready reports whether this executor can run queries without a further
	// install step (native is always ready; CLI needs LookPath success).
	Ready() bool
	QueryJSON(ctx context.Context, database, query string, maxBytes int) ([]byte, error)
}

Executor runs read-only SQL and returns sqlite3 -json shaped bytes (a JSON array).

func FromEnv

func FromEnv() (Executor, error)

FromEnv builds an executor using HERDR_SQLITE_BACKEND (default auto).

func MustFromEnv

func MustFromEnv() Executor

MustFromEnv returns FromEnv or a CLI fallback that reports not Ready when nothing works. Callers still check Ready/databases().

func Resolve

func Resolve(backend Backend, cliBinary string) (Executor, error)

Resolve builds an executor for the requested backend. cliBinary is the sqlite3 executable name or path used by the CLI backend.

Jump to

Keyboard shortcuts

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