query

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package query executes SQL through a conn.Pool, enforcing the safety gate, single-statement rule, optional row limit, and context timeout.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGuard          = errors.New("guard")
	ErrMultiStatement = errors.New("multi-statement")
	ErrSQL            = errors.New("sql")
	ErrTimeout        = errors.New("timeout")
)

Typed errors mapped by the cli layer to exit codes.

Functions

func Execute

func Execute(ctx context.Context, pool *conn.Pool, sqlText string, opts Options) (result.Result, error)

Execute runs a single SQL statement. It first applies the safety guard, then the multi-statement check, then executes with the given timeout and optional LIMIT wrapping for SELECT queries.

func ExecuteTxn

func ExecuteTxn(ctx context.Context, pool *conn.Pool, statements []string, opts Options) (result.Result, error)

ExecuteTxn runs multiple statements in one transaction atomically. Every statement is individually guarded; any error rolls back.

func ExecuteWrite

func ExecuteWrite(ctx context.Context, pool *conn.Pool, sqlText string, opts Options) (result.Result, error)

ExecuteWrite runs a single DML/DDL statement inside a transaction and commits. It enforces the same guard as Execute.

Types

type Options

type Options struct {
	Write   bool
	DDL     bool
	Yes     bool
	Limit   int
	Timeout time.Duration
}

Options controls execution permissions and limits.

Jump to

Keyboard shortcuts

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