API referencestd/db

std/db/sql

Public declarations, types, methods, and source contracts for std/db/sql.

On this page

Library guide · API index and notation

This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.

import "std/db/sql"

Names used in signatures

Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.

Alias Package Source file
db std/db sql.dodo
mem core/mem sql.dodo

Row

Interface · Source

pub interface Row {
    // Number of result columns.
    fn len(&self) -> usize
    // Column name as written in the statement (or its alias).
    fn name(&self, index: usize) -> &str
    // Column value. Text and Bytes borrow the driver's workspace.
    fn get(&self, index: usize) -> db.Value!db.Error
}

RowSink

Interface · Source

pub interface RowSink {
    fn row(&mut self, row: &dyn Row) -> void!db.Error
}

Conn

Interface · Source

pub interface Conn {
    // Runs one statement and returns the number of rows it changed.
    fn execute(&mut self, sql: &str, params: &[db.Value]) -> u64!db.Error
    // Runs one statement and passes every result row to `sink`.
    fn query(&mut self, sql: &str, params: &[db.Value], sink: &mut dyn RowSink) -> void!db.Error
    fn begin(&mut self, level: db.IsolationLevel) -> void!db.Error
    fn commit(&mut self) -> void!db.Error
    fn rollback(&mut self) -> void!db.Error
}

Count

Struct · Source

Counts rows and discards them.

pub struct Count {
    pub rows: u64
}

Count.new

Function · Source

pub fn new() -> Count

Count.row

Function · Source

pub fn row(&mut self, row: &dyn Row) -> void!db.Error

ScalarInt

Struct · Source

Captures the first column of the first row as an integer. NULL leaves found false; other non-integer values are a Type error.

pub struct ScalarInt {
    pub value: i64
    pub found: bool
}

ScalarInt.new

Function · Source

pub fn new() -> ScalarInt

ScalarInt.row

Function · Source

pub fn row(&mut self, row: &dyn Row) -> void!db.Error

column

Function · Source

Index of the column called name (exact, case-sensitive match). hint is checked first, so a caller that passes the expected position pays one comparison when the statement lists columns in that order. A missing column is a Schema error.

pub fn column<R: Row>(row: &R, name: &str, hint: usize) -> usize!db.Error

is_null

Function · Source

pub fn is_null(value: &db.Value) -> bool

boolean

Function · Source

Integer value; any nonzero integer is true. Other values are Type errors.

pub fn boolean(value: db.Value) -> bool!db.Error

int

Function · Source

Integer value. Other values, NULL included, are Type errors.

pub fn int(value: db.Value) -> i64!db.Error

int_in

Function · Source

Integer value within min..=max, for narrower integer fields. Values outside the range are Type errors rather than traps.

pub fn int_in(value: db.Value, min: i64, max: i64) -> i64!db.Error

real

Function · Source

Real value; integers convert. Other values are Type errors.

pub fn real(value: db.Value) -> f64!db.Error

real32

Function · Source

Real value that fits an f32. NaN, infinities and out-of-range values are Type errors, because narrowing them would trap.

pub fn real32(value: db.Value) -> f32!db.Error

text

Function · Source

Text value, borrowed from the row. Other values are Type errors.

pub fn text(value: db.Value) -> &str!db.Error from(value)

bytes

Function · Source

Blob value, or the UTF-8 bytes of a text value, borrowed from the row. Other values are Type errors.

pub fn bytes(value: db.Value) -> &[u8]!db.Error from(value)

Search every guide, reference page, and API declaration.