pub struct Connection { /* private fields */ }Implementations§
Source§impl Connection
impl Connection
Sourcepub fn trace_stmt(&mut self, f: TraceFn)
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.
Sourcepub fn open_memory() -> Result<Connection, SqlError>
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.
Sourcepub fn open_opfs(name: &str) -> Result<Connection, SqlError>
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.
Sourcepub fn execute_batch(&self, sql: &str) -> Result<(), SqlError>
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.
Sourcepub fn execute(&self, sql: &str, params: &[Value]) -> Result<u64, SqlError>
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.
Sourcepub fn query(
&self,
sql: &str,
params: &[Value],
f: &mut dyn FnMut(Vec<Value>),
) -> Result<(), SqlError>
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.
Sourcepub fn query_named(
&self,
sql: &str,
params: &[Value],
f: &mut dyn FnMut(&[String], Vec<Value>),
) -> Result<Vec<String>, SqlError>
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.