Struct PreparedStatement

Source
pub struct PreparedStatement { /* private fields */ }
Expand description

A prepared statement.

Implementations§

Source§

impl PreparedStatement

Source

pub fn execute(&mut self) -> ResultSet<'_>

Begin executing a statement.

An sqlite “row” only lasts until the next call to ffi::sqlite3_step(), so ResultSet has a corresponding lifetime constraint, which prevents it ResultSet from implementing the Iterator trait. See the Query trait for and Iterator over query results.

Source§

impl PreparedStatement

A compiled prepared statement that may take parameters. Note: “The leftmost SQL parameter has an index of 1.”1

Source

pub fn ignore_detail(&mut self)

Opt out of copies of error message details.

Source

pub fn bind_null(&mut self, i: ParamIx) -> SqliteResult<()>

Bind null to a statement parameter.

Source

pub fn bind_int(&mut self, i: ParamIx, value: i32) -> SqliteResult<()>

Bind an int to a statement parameter.

Source

pub fn bind_int64(&mut self, i: ParamIx, value: i64) -> SqliteResult<()>

Bind an int64 to a statement parameter.

Source

pub fn bind_double(&mut self, i: ParamIx, value: f64) -> SqliteResult<()>

Bind a double to a statement parameter.

Source

pub fn bind_text(&mut self, i: ParamIx, value: &str) -> SqliteResult<()>

Bind a (copy of a) str to a statement parameter.

TODO: support binding without copying strings, blobs

Source

pub fn bind_blob(&mut self, i: ParamIx, value: &[u8]) -> SqliteResult<()>

Bind a (copy of a) byte sequence to a statement parameter.

TODO: support binding without copying strings, blobs

Source

pub fn clear_bindings(&mut self)

Clear all parameter bindings.

Source

pub fn bind_parameter_count(&mut self) -> ParamIx

Return the number of SQL parameters. If parameters of the ?NNN form are used, there may be gaps in the list.

Source

pub unsafe fn expose(&mut self) -> *mut sqlite3_stmt

Expose the underlying sqlite3_stmt struct pointer for use with the ffi module.

Source

pub fn changes(&self) -> u64

Return the number of database rows that were changed or inserted or deleted by this statement if it is the most recently run on its database connection.

cf sqlite3_changes.

Trait Implementations§

Source§

impl Drop for PreparedStatement

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<F, T> Query<F, T> for PreparedStatement
where F: FnMut(&mut ResultRow<'_, '_>) -> SqliteResult<T>,

Source§

fn query<'stmt>( &'stmt mut self, values: &[&dyn ToSql], txform: F, ) -> SqliteResult<QueryResults<'stmt, T, F>>

Iterate over query results after binding parameters. Read more
Source§

impl<F> QueryEach<F> for PreparedStatement
where F: FnMut(&mut ResultRow<'_, '_>) -> SqliteResult<()>,

Source§

fn query_each( &mut self, values: &[&dyn ToSql], each_row: &mut F, ) -> SqliteResult<()>

Process rows from a query after binding parameters.

For call each_row(row) for each resulting step, exiting on Err.

Source§

impl<F, A> QueryFold<F, A> for PreparedStatement
where F: Fn(&mut ResultRow<'_, '_>, A) -> SqliteResult<A>,

Source§

fn query_fold( &mut self, values: &[&dyn ToSql], init: A, f: F, ) -> SqliteResult<A>

Fold rows from a query after binding parameters.

Source§

impl StatementUpdate for PreparedStatement

Source§

fn update(&mut self, values: &[&dyn ToSql]) -> SqliteResult<u64>

Execute a statement after binding any parameters.

When the statement is done, The number of rows modified is reported.

Fail with Err(SQLITE_MISUSE) in case the statement results in any any rows (e.g. a SELECT rather than INSERT or UPDATE).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.