pub struct Connection { /* private fields */ }Expand description
A SQLite database connection.
Closed when dropped. Not Sync – all access must happen from a single
thread (matches the WASM single-thread constraint and the native
Mutex-guarded usage in CredentialStoreInner).
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn execute_batch(&self, sql: &str) -> DbResult<()>
pub fn execute_batch(&self, sql: &str) -> DbResult<()>
Executes one or more SQL statements separated by semicolons.
No result rows are returned. Suitable for DDL, PRAGMAs, and multi-statement scripts.
§Errors
Returns Error if any statement fails.
Sourcepub fn execute_batch_zeroized(&self, sql: &str) -> DbResult<()>
pub fn execute_batch_zeroized(&self, sql: &str) -> DbResult<()>
Like execute_batch but zeroizes the internal
C string buffer after execution. Use for SQL containing sensitive
material (e.g. PRAGMA key).
§Errors
Returns Error if the statement fails.
Sourcepub fn execute(&self, sql: &str, params: &[Value]) -> DbResult<usize>
pub fn execute(&self, sql: &str, params: &[Value]) -> DbResult<usize>
Prepares and executes a single SQL statement with the given parameters.
Returns the number of rows changed.
§Errors
Returns Error if preparation or execution fails.
Sourcepub fn query_row<T>(
&self,
sql: &str,
params: &[Value],
mapper: impl FnOnce(&Row<'_, '_>) -> DbResult<T>,
) -> DbResult<T>
pub fn query_row<T>( &self, sql: &str, params: &[Value], mapper: impl FnOnce(&Row<'_, '_>) -> DbResult<T>, ) -> DbResult<T>
Prepares and executes a statement, mapping exactly one result row.
Returns an error if no row is returned.
§Errors
Returns Error if preparation, execution, or the mapper fails,
or if the query returns no rows.
Sourcepub fn query_row_optional<T>(
&self,
sql: &str,
params: &[Value],
mapper: impl FnOnce(&Row<'_, '_>) -> DbResult<T>,
) -> DbResult<Option<T>>
pub fn query_row_optional<T>( &self, sql: &str, params: &[Value], mapper: impl FnOnce(&Row<'_, '_>) -> DbResult<T>, ) -> DbResult<Option<T>>
Sourcepub fn transaction(&self) -> DbResult<Transaction<'_>>
pub fn transaction(&self) -> DbResult<Transaction<'_>>
Sourcepub fn transaction_immediate(&self) -> DbResult<Transaction<'_>>
pub fn transaction_immediate(&self) -> DbResult<Transaction<'_>>
Begins an immediate transaction (acquires a RESERVED lock right away).
§Errors
Returns Error if BEGIN IMMEDIATE fails.
Sourcepub fn last_insert_rowid(&self) -> i64
pub fn last_insert_rowid(&self) -> i64
Returns the rowid of the most recent successful INSERT.