pub struct Statement { /* private fields */ }
Expand description

A prepared statement.

Implementations§

Bind values to parameters.

In case of integer indices, the first parameter has index 1.

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.

In case of integer indices, the first column has index 0.

Return column names.

Return the type of a column.

The type becomes available after taking a step. In case of integer indices, the first column has index 0.

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.

In case of integer indices, the first column has index 0.

Reset the internal state.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.