sqlite

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package sqlite is the builtin Orchard provider for SQLite.

It implements one action, "sqlite_query": run a SQL statement and capture the first returned row as outputs, or, for statements that return no rows, the last insert id and affected-row count. It uses modernc.org/sqlite, a pure-Go driver, so release builds stay CGO-free.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is the SQLite provider implementation.

A zero Provider is valid but not yet usable — Configure must be called before Execute. Schema works on a zero Provider so the engine can validate scenarios before a database is opened.

func New

func New() *Provider

New returns an unconfigured SQLite provider. Schema is parsed once up front so an error in the embedded schema.hcl fails at binary startup rather than at first use.

func (*Provider) Close

func (p *Provider) Close() error

Close closes the database. Safe to call on an unconfigured provider or to call multiple times.

func (*Provider) Configure

func (p *Provider) Configure(ctx context.Context, config map[string]cty.Value) error

Configure opens the database at the path config attribute. Like sql.Open everywhere, this does not touch the file; Execute surfaces open errors on first use.

The pool is capped at one connection. That keeps `:memory:` databases (which are per-connection) shared across every action, and makes last_insert_rowid()/changes() refer to the statement the action just ran. ponytail: one connection serialises actions; revisit if parallel execution lands (Milestone 6), keeping :memory: on one conn.

func (*Provider) Execute

func (p *Provider) Execute(ctx context.Context, action string, attrs map[string]cty.Value) (map[string]cty.Value, error)

Execute dispatches to the handler for the given action.

func (*Provider) ExecuteUndo

func (p *Provider) ExecuteUndo(ctx context.Context, action string, attrs map[string]cty.Value, opts provider.InverseOptions) (map[string]cty.Value, *provider.Invocation, error)

ExecuteUndo runs an action like Execute and, for a typed action, also describes its automatic teardown: deleting an inserted row by its primary key, or restoring the previous values of rows an update changed.

func (*Provider) PlanAction

func (p *Provider) PlanAction(ctx context.Context, action string, attrs map[string]cty.Value) (provider.Plan, error)

PlanAction checks a typed action before the run: against the live schema after Configure, or the snapshot during `orchard plan`.

func (*Provider) PlanConfigure

func (p *Provider) PlanConfigure(_ context.Context, _ map[string]cty.Value, snap *snapshot.Snapshot) error

PlanConfigure loads the schema snapshot `orchard plan` checks typed actions against. Without one, typed actions go unchecked at plan time. It doesn't connect.

func (*Provider) PullSchema

func (p *Provider) PullSchema(ctx context.Context, _ provider.PullOptions) (*provider.Capture, error)

PullSchema captures the database's tables (not views). SQLite has one namespace, so opts.Schemas is ignored.

func (*Provider) Schema

func (p *Provider) Schema() protocol.ProviderSchema

Schema returns the embedded provider schema.

Jump to

Keyboard shortcuts

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