Skip to main content

Connection

Struct Connection 

Source
pub struct Connection { /* private fields */ }

Implementations§

Source§

impl Connection

Source

pub fn trace_stmt(&mut self, f: TraceFn)

Install the engine’s per-statement trace (sqlite3_trace_v2, SQLITE_TRACE_STMT): f sees every statement this connection executes, with bound parameters expanded.

Source

pub fn open_memory() -> Result<Connection, SqlError>

A private in-memory database, the only kind the main-thread app instance may open.

§Errors

Returns the engine error when the database cannot be opened.

Source

pub fn open_opfs(name: &str) -> Result<Connection, SqlError>

A named database through the day-opfs VFS (real OPFS in the worker, the in-memory fake in native tests).

§Errors

Returns the engine error when the database cannot be opened.

Source

pub fn execute_batch(&self, sql: &str) -> Result<(), SqlError>

Run semicolon-separated statements with no parameters and no rows.

§Errors

Returns the engine error of the first statement that fails to prepare or run.

Source

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

Run one statement; the count of changed rows comes back.

§Errors

Returns the engine error when the statement is empty, or fails to prepare, bind or run.

Source

pub fn query( &self, sql: &str, params: &[Value], f: &mut dyn FnMut(Vec<Value>), ) -> Result<(), SqlError>

Run one statement, delivering each row to f.

§Errors

Returns the engine error when the statement is empty, or fails to prepare, bind or run.

Source

pub fn query_named( &self, sql: &str, params: &[Value], f: &mut dyn FnMut(&[String], Vec<Value>), ) -> Result<Vec<String>, SqlError>

Query with result column names, including aliases. Names are returned even for no rows.

§Errors

Returns the engine error when the statement is empty, or fails to prepare, bind or run.

Trait Implementations§

Source§

impl Drop for Connection

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.