v2026.11.2
All Bundles
Bundle

In-memory query engine over typed columns. Tables are filled row by row or loaded from sources (CSV files, folders, the program's own objects) and queried with SQL-like statements; aggregates, Describe() and Finder (file search) are included. Compile with -lib query.

Statement

A statement parsed once and run many times, with '?' placeholders for values bound before each run. Placeholders are numbered from 1, left to right. A SELECT runs with Execute; an INSERT, UPDATE, DELETE or CREATE TABLE with ExecuteUpdate.

Example

statement := table->Prepare("select id, score from runs where score > ? and label = ?");
statement->Bind(1, 0.5)->Bind(2, "cat");
results := statement->Execute();

Operations

Bind #

Binds a value to a placeholder

method : public : Bind(index:Int, value:Compare) ~ Statement

Parameters

NameTypeDescription
indexIntplaceholder number, from 1
valueComparevalue

Return

TypeDescription
Statementthis statement

Bind #

Binds an Int to a placeholder

method : public : Bind(index:Int, value:Int) ~ Statement

Parameters

NameTypeDescription
indexIntplaceholder number, from 1
valueIntvalue

Return

TypeDescription
Statementthis statement

Bind #

Binds a Float to a placeholder

method : public : Bind(index:Int, value:Float) ~ Statement

Parameters

NameTypeDescription
indexIntplaceholder number, from 1
valueFloatvalue

Return

TypeDescription
Statementthis statement

Bind #

Binds a Bool to a placeholder

method : public : Bind(index:Int, value:Bool) ~ Statement

Parameters

NameTypeDescription
indexIntplaceholder number, from 1
valueBoolvalue

Return

TypeDescription
Statementthis statement

BindNull #

Binds NULL to a placeholder: an empty cell in INSERT and UPDATE; in a condition, a comparison no row passes, as every comparison with an empty cell is false

method : public : BindNull(index:Int) ~ Statement

Parameters

NameTypeDescription
indexIntplaceholder number, from 1

Return

TypeDescription
Statementthis statement

Execute #

Runs the query, copying the result into a new table

method : public : Execute() ~ Table

Return

TypeDescription
Tableresult table, Nil on error (see GetError)

ExecuteUpdate #

Runs an INSERT, UPDATE, DELETE, CREATE TABLE, CREATE INDEX or DROP INDEX (see Table->Execute). A statement that fails changes nothing.

method : public : ExecuteUpdate() ~ Int

Return

TypeDescription
Introws inserted, updated or deleted (0 for CREATE TABLE), -1 on error (see GetError)

ExecuteView #

Runs the query without copying the result

method : public : ExecuteView() ~ View

Return

TypeDescription
Viewresult view, Nil on error (see GetError)

Explain #

Tells how the statement reads its rows with the values bound now (see Table->Explain); a SELECT is run to find out, an UPDATE or DELETE is not

method : public : Explain() ~ String

Return

TypeDescription
Stringplan, Nil on error (see GetError)

Example

s := table->Prepare("select * from runs where score > ?");
s->Bind(1, 0.9);
s->Explain()->PrintLine(); # where runs: SORTED index runs_score on score (>)

GetError #

Gets the reason the last run failed

method : public : GetError() ~ String

Return

TypeDescription
Stringerror, Nil if none

GetParamCount #

Gets the number of placeholders

method : public : GetParamCount() ~ Int

Return

TypeDescription
Intplaceholder count

IsQuery #

Whether the statement is a SELECT, which Execute runs; INSERT, UPDATE, DELETE and CREATE TABLE run with ExecuteUpdate

method : public : IsQuery() ~ Bool

Return

TypeDescription
Booltrue for a SELECT

New # constructor

Constructor. Use Table->Prepare rather than this.

New(table:Table, plan:Plan)

Parameters

NameTypeDescription
tableTabletable
planPlanparsed statement

New # constructor

Constructor. Use Catalog->Prepare rather than this.

New(catalog:Catalog, plan:Plan)

Parameters

NameTypeDescription
catalogCatalogcatalog
planPlanparsed statement