Documentation
¶
Overview ¶
Package dataset runs a read-only query against a data store and returns its rows. It is the dataset family of requests (see model.Family): a query goes out, rows come back.
A Source runs the queries of one kind of store. Registry maps the driver names a request may use to Sources, so a new store (a CSV file, say) is one more Source and nothing that already works changes. The SQL sources use pure Go drivers only: no cgo, so the lib and the CLI still build everywhere with CGO_ENABLED=0.
Index ¶
Constants ¶
const DefaultTimeout = 30 * time.Second
DefaultTimeout is how long a query may take when it sets no timeout.
Variables ¶
var ( // ErrUnknownDriver is returned for a driver that is not in the registry. ErrUnknownDriver = errors.New("unknown dataset driver") // ErrTimeout is returned when the query did not finish in its timeout. ErrTimeout = errors.New("the query timed out") )
The errors a query can end in besides the store's own.
Functions ¶
This section is empty.
Types ¶
type Query ¶
type Query struct {
Driver string
Server string
Statement string
Params []string
// Limit is the most rows kept; 0 means model.DefaultDatasetLimit.
Limit int
// Root is the directory a relative file path (sqlite) is resolved against.
Root string
// Timeout bounds connecting and running together; 0 means DefaultTimeout.
Timeout time.Duration
}
Query is one query to run. Statement is sent as written; Params are sent apart from it.
type Result ¶
type Result struct {
Columns []string
Rows [][]any
// Truncated is true when the store had more rows than Limit.
Truncated bool
Duration time.Duration
}
Result is what a query returned. Every row has one value per column, in column order; a column that repeats a name gets a numbered suffix (a, a_2) so a row can also be read by name.