Skip to main content

PreparedStatement

Struct PreparedStatement 

Source
pub struct PreparedStatement<'c, 'db> { /* private fields */ }
Expand description

A prepared SQL statement bound to a Connection.

Implementations§

Source§

impl<'c, 'db> PreparedStatement<'c, 'db>

Source

pub fn sql(&self) -> &str

The original SQL text.

Source

pub fn param_count(&self) -> usize

Number of positional parameters ($1, $2, …) this statement expects.

Source

pub fn parameter_count(&self) -> usize

Alias of Self::param_count matching rusqlite’s name.

Source

pub fn column_count(&self) -> usize

Number of output columns. Zero for non-SELECT statements.

Source

pub fn column_names(&self) -> &[String]

Output column names in declaration order.

Source

pub fn column_name(&self, i: usize) -> Option<&str>

Output column name at index i, if any.

Source

pub fn column_index(&self, name: &str) -> Option<usize>

Position of the column named name, if present.

Source

pub fn readonly(&self) -> bool

True if the statement is read-only (SELECT or EXPLAIN).

Source

pub fn is_explain(&self) -> bool

True if the statement is an EXPLAIN.

Source

pub fn execute(&self, params: &[Value]) -> Result<u64>

Execute the statement; returns rows affected (0 for SELECT/DDL).

Source

pub fn query(&self, params: &[Value]) -> Result<Rows<'_>>

Execute and return a stepping Rows<'_> iterator.

Streams rows directly from the B+ tree for simple SELECT [cols] FROM t shapes (no WHERE/ORDER BY/aggregate/join). Materializes internally for everything else — same user-visible API either way.

DML statements execute the mutation and yield an immediately-exhausted Rows (matching rusqlite semantics).

Source

pub fn query_collect(&self, params: &[Value]) -> Result<QueryResult>

Execute and return the fully-materialized QueryResult.

Equivalent to self.query(params)?.collect() but slightly more direct.

Source

pub fn query_row<T, F>(&self, params: &[Value], f: F) -> Result<T>
where F: FnOnce(&Row<'_>) -> Result<T>,

Run the query and pass the first row to f.

Returns SqlError::QueryReturnedNoRows if the query produced zero rows. Extra rows after the first are ignored (matches rusqlite’s query_row).

Source

pub fn exists(&self, params: &[Value]) -> Result<bool>

True if the query returns at least one row (DML returns n > 0).

For streamable SELECTs this short-circuits on the first matching row without materializing the rest.

Auto Trait Implementations§

§

impl<'c, 'db> Freeze for PreparedStatement<'c, 'db>

§

impl<'c, 'db> !RefUnwindSafe for PreparedStatement<'c, 'db>

§

impl<'c, 'db> !Send for PreparedStatement<'c, 'db>

§

impl<'c, 'db> !Sync for PreparedStatement<'c, 'db>

§

impl<'c, 'db> Unpin for PreparedStatement<'c, 'db>

§

impl<'c, 'db> UnsafeUnpin for PreparedStatement<'c, 'db>

§

impl<'c, 'db> !UnwindSafe for PreparedStatement<'c, 'db>

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V