SqlExecution extension

Executes reusable SQL on the current database, session or transaction.

on

Methods

query<R>(SqlQuery<R> query, {ExecutionOptions options = const ExecutionOptions(), Iterable<TableSchema> changedTables = const []}) Future<List<R>>

Available on QueryContext, provided by the SqlExecution extension

Executes once and decodes the actual metadata and rows. No wrapper or LIMIT is added. Use this for SELECT or native DML RETURNING.
raw(Sql sql, {ExecutionOptions options = const ExecutionOptions(), Iterable<TableSchema> changedTables = const []}) Future<SqlResult>

Available on QueryContext, provided by the SqlExecution extension

Executes exactly the supplied statement and returns positional rows, labels and write metadata. Raw writes declare changedTables for watches.
streamSql<R>(SqlQuery<R> query, {int batchSize = 128, ExecutionOptions options = const ExecutionOptions()}) Stream<R>

Available on QueryContext, provided by the SqlExecution extension

Streams typed rows through one cursor with bounded batch fetching. Compilation is immediate; a connection is acquired on listen. Result labels are bound on the first batch, even when empty, without a second query. Cancel or finish before leaving a session/transaction callback.