Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlquery

package
v0.300.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDestructiveQuery

func IsDestructiveQuery(query string) bool

IsDestructiveQuery reports whether the query deletes or drops resources. This is a best-effort guardrail for agents, not a SQL parser. Statements led by DELETE, DROP, or TRUNCATE (including after CTEs) require approval.

Types

type DestructiveQueryError

type DestructiveQueryError struct{}

DestructiveQueryError is returned when a query would delete or drop data or schema objects and --force was not passed.

func (*DestructiveQueryError) Error

func (e *DestructiveQueryError) Error() string

type Options

type Options struct {
	Organization string
	Database     string
	Branch       string
	Query        string
	// Keyspace is the Vitess keyspace for MySQL. Optional; defaults to @primary (same as pscale shell).
	Keyspace string
	// PostgresDB is the PostgreSQL database name. Defaults to postgres.
	PostgresDB string
	// Role is reader, writer, readwriter, or admin (same as pscale shell --role).
	Role string
	// Replica routes reads to replicas when true (same as pscale shell --replica).
	Replica bool
	// Force allows destructive SQL (DELETE, DROP, TRUNCATE) after explicit user approval.
	Force bool
}

Options selects the branch and SQL to execute.

type Result

type Result struct {
	Status       string           `json:"status"`
	Database     string           `json:"database"`
	Branch       string           `json:"branch"`
	Kind         string           `json:"kind"`
	Role         string           `json:"role,omitempty"`
	Replica      bool             `json:"replica,omitempty"`
	RowCount     int              `json:"row_count"`
	RowsAffected int64            `json:"rows_affected,omitempty"`
	Columns      []string         `json:"columns,omitempty"`
	Rows         []map[string]any `json:"rows,omitempty"`
	NextSteps    []string         `json:"next_steps,omitempty"`
}

Result is returned for `pscale sql --format json`.

func Execute

func Execute(ctx context.Context, ch *cmdutil.Helper, opts Options) (*Result, error)

Execute runs SQL against MySQL or PostgreSQL using ephemeral credentials.

Jump to

Keyboard shortcuts

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