pub struct Statement<'l> { /* private fields */ }
Expand description
A prepared statement.
Implementations
sourceimpl<'l> Statement<'l>
impl<'l> Statement<'l>
sourcepub fn bind<T: Bindable>(self, i: usize, value: T) -> Result<Self>
pub fn bind<T: Bindable>(self, i: usize, value: T) -> Result<Self>
Bind a value to a parameter by index.
The first parameter has index 1.
sourcepub fn bind_by_name<T: Bindable>(self, name: &str, value: T) -> Result<Self>
pub fn bind_by_name<T: Bindable>(self, name: &str, value: T) -> Result<Self>
Bind a value to a parameter by name.
Examples
let mut statement = connection.prepare("SELECT * FROM users WHERE name = :name")?;
statement.bind_by_name(":name", "Bob")?;
sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Return the number of columns.
sourcepub fn column_name(&self, i: usize) -> &str
pub fn column_name(&self, i: usize) -> &str
Return the name of a column.
The first column has index 0.
sourcepub fn column_names(&self) -> Vec<&str>
pub fn column_names(&self) -> Vec<&str>
Return column names.
sourcepub fn column_type(&self, i: usize) -> Type
pub fn column_type(&self, i: usize) -> Type
Return the type of a column.
The first column has index 0. The type becomes available after taking a step.
sourcepub fn next(&mut self) -> Result<State>
pub fn next(&mut self) -> Result<State>
Advance to the next state.
The function should be called multiple times until State::Done
is
reached in order to evaluate the statement entirely.
sourcepub fn parameter_index(&self, parameter: &str) -> Result<Option<usize>>
pub fn parameter_index(&self, parameter: &str) -> Result<Option<usize>>
Return the index for a named parameter if exists.
Examples
let statement = connection.prepare("SELECT * FROM users WHERE name = :name")?;
assert_eq!(statement.parameter_index(":name")?.unwrap(), 1);
assert_eq!(statement.parameter_index(":asdf")?, None);
sourcepub fn read<T: Readable>(&self, i: usize) -> Result<T>
pub fn read<T: Readable>(&self, i: usize) -> Result<T>
Read a value from a column.
The first column has index 0.
sourcepub fn into_cursor(self) -> Cursor<'l>ⓘNotable traits for Cursor<'l>impl<'l> Iterator for Cursor<'l> type Item = Result<Row>;
pub fn into_cursor(self) -> Cursor<'l>ⓘNotable traits for Cursor<'l>impl<'l> Iterator for Cursor<'l> type Item = Result<Row>;
Upgrade to a cursor.
sourcepub fn as_raw(&self) -> *mut sqlite3_stmt
pub fn as_raw(&self) -> *mut sqlite3_stmt
Return the raw pointer.
Trait Implementations
Auto Trait Implementations
impl<'l> RefUnwindSafe for Statement<'l>
impl<'l> !Send for Statement<'l>
impl<'l> !Sync for Statement<'l>
impl<'l> Unpin for Statement<'l>
impl<'l> UnwindSafe for Statement<'l>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more