Row.peek

Returns the data of a column directly.

Contrary to opIndex, the peek functions return the data directly, automatically cast to T, without the overhead of using a wrapping type (ColumnData).

When using peek to retrieve an array or a string, you can use either:

  • peek!(..., PeekMode.copy)(index), in which case the function returns a copy of the data that will outlive the step to the next row, or
  • peek!(..., PeekMode.slice)(index), in which case a slice of SQLite's internal buffer is returned (see Warnings).

Parameters

T

The type of the returned data. T must be a boolean, a built-in numeric type, a string, an array or a Nullable.

Condition on TRequested database type
isIntegral!T || isBoolean!TINTEGER
isFloatingPoint!TFLOAT
isSomeString!TTEXT
isArray!TBLOB
is(T == Nullable!U, U...)NULL or U
index size_t

The index of the column in the prepared statement or the name of the column, as specified in the prepared statement with an AS clause. The index of the first column is 0.

Return Value

Type: T

A value of type T. The returned value results from SQLite's own conversion rules: see http://www.sqlite.org/c3ref/column_blob.html and http://www.sqlite.org/lang_expr.html#castexpr. It's then converted to T using std.conv.to!T.

Warnings: When using PeekMode.slice, the data of the slice will be invalidated when the next row is accessed. A copy of the data has to be made somehow for it to outlive the next step on the same statement.

When using referring to the column by name, the names of all the columns are tested each time this function is called: use numeric indexing for better performance.

Meta