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 ¶
- func New(env core.Env, c *spec.Component) (any, error)
- type DB
- func (d *DB) Actions() []core.Action
- func (d *DB) Activity(ctx context.Context) (core.Activity, error)
- func (d *DB) Browse(ctx context.Context, path []string) (core.Table, bool, error)
- func (d *DB) Close() error
- func (d *DB) CreateDatabase(ctx context.Context, name string) error
- func (d *DB) Databases(ctx context.Context) ([]string, error)
- func (d *DB) Delete(ctx context.Context, path []string, t core.Table, rows []int) error
- func (d *DB) DropDatabase(ctx context.Context, name string) error
- func (d *DB) Exec(ctx context.Context, db, q string) (int64, error)
- func (d *DB) Fresh(ctx context.Context) (bool, error)
- func (d *DB) Host() string
- func (d *DB) Ping(ctx context.Context) error
- func (d *DB) Query(ctx context.Context, db, q string) (core.Table, error)
- func (d *DB) QueryAt(ctx context.Context, path []string, q string) (core.Table, error)
- func (d *DB) QueryLanguage() string
- func (d *DB) Restore(ctx context.Context, file string, log io.Writer) error
- func (d *DB) RunQuery(ctx context.Context, q string) (core.Table, error)
- func (d *DB) Seed(ctx context.Context, out io.Writer) error
- func (d *DB) Set(ctx context.Context, path []string, t core.Table, row, col int, value string) error
- func (d *DB) Snapshot(ctx context.Context, file string, log io.Writer) error
- func (d *DB) SuggestQuery(ctx context.Context, path []string) string
- func (d *DB) SuggestRowQuery(ctx context.Context, path []string, t core.Table, row int) string
- type Options
- type Seed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) Browse ¶
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) Fresh ¶
Fresh is whether the database has no tables of its own yet (or does not exist), waiting up to 30s for a server that is still starting.
func (*DB) QueryLanguage ¶
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) Snapshot ¶
Snapshot dumps the database into file: pg_dump or mysqldump on this machine, or inside the database's container when this machine has none (or a different version); SQL Server backs up to its own disk and the file is copied out of its container.
func (*DB) SuggestQuery ¶
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.
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"`
// Seed fills the database: rig data seed, and rig up when it starts the database empty.
Seed []Seed `yaml:"seed"`
Seeds []Seed `yaml:"seeds"` // the old name of seed
// Clear holds the statements `clear` runs to empty the run's data without recreating the database.
Clear []string `yaml:"clear"`
}