gizdb:workbench
Interactive SQL sessions reuse Source adapters and the SQL parser. Products own connection records, credential access, authorization and saved work.
import * as Workbench from "gizdb:workbench";Types
ResultSet
type ResultSet = { columns: Vec<string>; rows: Vec<Vec<Option<string>>>; truncated: bool; }A query's column names and rows (null as none); truncated when more rows than the limit matched.
columns:Vec<string>rows:Vec<Vec<_gizlang_sdk_core.Option<string>>>truncated:bool
Admission
type Admission = { privateNetwork: bool; localFiles: bool; driverStrings: bool; }Local files and raw driver connection strings require explicit host admission.
privateNetwork:boollocalFiles:booldriverStrings:bool
Session
type Session = { source: Source.Source; close: () => void; execute: (sql: string, expected: Option<i64>) => Result<i64, string>; }An open SQL session: its Source, how to close it and, when writable, how to run a change expecting a row count.
source:M85.Sourceclose:() => voidexecute:(sql: string, expected: _gizlang_sdk_core.Option<i64>) => _gizlang_sdk_core.Result<i64, string>
Functions
readOnly
function readOnly(sql: string): string throws stringsql without trailing semicolons when it is one SELECT, WITH or VALUES statement.
Effects: fail, read, write, console, io.
reachable
function reachable(sys: System, location: string, admission: Admission): Pg.Options throws stringThe PostgreSQL options of location, its host resolved and admitted by admission.
Effects: fail, io.
open
function open(sys: System, location: string, dialect: string, admission: Admission, writable: bool = false): Session throws stringA session on the database at location (postgres://, mysql://, odbc: or a local file), read-only unless writable.
Effects: fail, read, write, console, io.
held
function held(database: Store.Database, writable: bool = false): Session throws stringA session on the open store database, read-only unless writable; closing the session closes the database.
Effects: fail, read, write, console, io.
query
function query(session: Session, sql: string, limit: i64 = ROWS): ResultSet throws stringThe first limit rows of the read-only statement sql.
Effects: fail, read, write, console, io.
tables
function tables(session: Session): ResultSet throws stringThe tables and views of the session's database: schema, name and type.
Effects: fail, read, write, console, io.
columns
function columns(session: Session, schema: string, table: string): ResultSet throws stringThe columns of schema.table: name, type, nullability and default.
Effects: fail, read, write, console, io.
Constants
ROWS
const ROWS = 1000The most rows a query returns.
BYTES
const BYTES = 16777216The most bytes a query reads.