sql

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package sql is the database adapter for SQL servers: one implementation, a dialect per driver (postgres, mssql, mysql) for listing, creating and dropping databases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(env core.Env, c *spec.Component) (any, error)

Types

type DB

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

func (*DB) Actions

func (d *DB) Actions() []core.Action

func (*DB) Browse

func (d *DB) Browse(ctx context.Context, path []string) (core.Table, bool, error)

Browse walks the server: databases, then a database's object kinds, then the objects, then one object's first rows (tables, views) or definition (procedures, functions).

func (*DB) Close

func (d *DB) Close() error

func (*DB) CreateDatabase

func (d *DB) CreateDatabase(ctx context.Context, name string) error

func (*DB) Databases

func (d *DB) Databases(ctx context.Context) ([]string, error)

func (*DB) Delete

func (d *DB) Delete(ctx context.Context, path []string, t core.Table, rows []int) error

func (*DB) DropDatabase

func (d *DB) DropDatabase(ctx context.Context, name string) error

func (*DB) Exec

func (d *DB) Exec(ctx context.Context, db, q string) (int64, error)

func (*DB) Ping

func (d *DB) Ping(ctx context.Context) error

func (*DB) Query

func (d *DB) Query(ctx context.Context, db, q string) (core.Table, error)

func (*DB) QueryAt

func (d *DB) QueryAt(ctx context.Context, path []string, q string) (core.Table, error)

QueryAt runs q in the database the path starts at.

func (*DB) QueryLanguage

func (d *DB) QueryLanguage() string

func (*DB) RunQuery

func (d *DB) RunQuery(ctx context.Context, q string) (core.Table, error)

RunQuery runs q on the default database; "@name <sql>" picks another.

func (*DB) Set

func (d *DB) Set(ctx context.Context, path []string, t core.Table, row, col int, value string) error

Set writes value into one cell; the text NULL stores NULL.

func (*DB) SuggestQuery

func (d *DB) SuggestQuery(ctx context.Context, path []string) string

SuggestQuery reads a table or view's first rows, and calls a procedure or function with each parameter as NULL /* its type */ to fill in; elsewhere it leaves a SELECT to finish.

func (*DB) SuggestRowQuery

func (d *DB) SuggestRowQuery(ctx context.Context, path []string, t core.Table, row int) string

SuggestRowQuery reads the row back by its primary key, or by its first column when it has none.

type Options

type Options struct {
	Driver   string            `yaml:"driver"`
	Addr     string            `yaml:"addr"`
	User     string            `yaml:"user"`
	Password string            `yaml:"password"`
	Database string            `yaml:"database"`
	Params   map[string]string `yaml:"params"`
	Seeds    []Seed            `yaml:"seeds"`
	// Clear holds the statements `clear` runs to empty the run's data without recreating the database.
	Clear []string `yaml:"clear"`
}

type Seed

type Seed struct {
	File string `yaml:"file"`
	DB   string `yaml:"db"`
}

Jump to

Keyboard shortcuts

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