Struct sqlite::Statement

source ·
pub struct Statement<'l> { /* private fields */ }
Expand description

A prepared statement.

Implementations

Bind values to parameters.

Examples
let query = "SELECT * FROM users WHERE name = ?";
let mut statement = connection.prepare(query)?;
statement.bind((1, "Bob"))?;
let query = "SELECT * FROM users WHERE name = ?";
let mut statement = connection.prepare(query)?;
statement.bind(&[(1, "Bob")][..])?;
let query = "SELECT * FROM users WHERE name = :name";
let mut statement = connection.prepare(query)?;
statement.bind((":name", "Bob"))?;
let query = "SELECT * FROM users WHERE name = :name";
let mut statement = connection.prepare(query)?;
statement.bind(&[(":name", "Bob")][..])?;
let query = "SELECT * FROM users WHERE id = :id AND name = :name";
let mut statement = connection.prepare(query)?;
statement.bind::<&[(_, Value)]>(&[
    (":id", 1.into()),
    (":name", "Bob".into()),
][..])?;

Bind values to parameters via an iterator.

Examples
let query = "INSERT INTO users VALUES (:id, :name)";
let mut statement = connection.prepare(query)?;
statement.bind_iter::<_, (_, Value)>([
    (":name", "Bob".into()),
    (":id", 42.into()),
])?;

Return the number of columns.

Return the name of a column.

Return column names.

Return the type of a column.

The type becomes available after taking a step.

Create a cursor.

Advance to the next state.

The function should be called multiple times until State::Done is reached in order to evaluate the statement entirely.

Return the index for a named parameter if exists.

Examples
let query = "SELECT * FROM users WHERE name = :name";
let statement = connection.prepare(query)?;
assert_eq!(statement.parameter_index(":name")?.unwrap(), 1);
assert_eq!(statement.parameter_index(":asdf")?, None);

Read a value from a column.

Reset the internal state.

Trait Implementations

Executes the destructor for this type. Read more
Converts to this type from the input type.
Converts to this type from the input type.
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.