Skip to main content

SqliteConnection

Trait SqliteConnection 

Source
pub trait SqliteConnection: 'static {
    // Required methods
    fn execute(&mut self, sql: &str, params: &[Value]) -> Result<u64, DbError>;
    fn query(
        &mut self,
        sql: &str,
        params: &[Value],
        row: &mut dyn FnMut(&dyn Row),
    ) -> Result<(), DbError>;

    // Provided methods
    fn begin(&mut self) -> Result<(), DbError> { ... }
    fn commit(&mut self) -> Result<(), DbError> { ... }
    fn rollback(&mut self) -> Result<(), DbError> { ... }
    fn execute_batch(&mut self, sql: &str) -> Result<(), DbError> { ... }
    fn query_named(
        &mut self,
        sql: &str,
        params: &[Value],
        row: &mut dyn FnMut(&[String], &dyn Row),
    ) -> Result<(), DbError> { ... }
}
Expand description

One open connection. Everything above speaks plain SQL and Values through it.

Required Methods§

Source

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

Run one statement and return the number of rows it changed.

§Errors

Returns the engine’s error when the statement fails.

Source

fn query( &mut self, sql: &str, params: &[Value], row: &mut dyn FnMut(&dyn Row), ) -> Result<(), DbError>

Run one statement, handing each result row to row.

§Errors

Returns the engine’s error when the statement fails.

Provided Methods§

Source

fn begin(&mut self) -> Result<(), DbError>

Begin a transaction.

§Errors

Returns the engine’s error when the statement fails.

Source

fn commit(&mut self) -> Result<(), DbError>

Commit the open transaction.

§Errors

Returns the engine’s error when the statement fails.

Source

fn rollback(&mut self) -> Result<(), DbError>

Roll the open transaction back.

§Errors

Returns the engine’s error when the statement fails.

Source

fn execute_batch(&mut self, sql: &str) -> Result<(), DbError>

Several statements in one string, no parameters: a DDL script, a migration step (day-lite’s storage speaks this). The default runs the string as one statement; drivers whose engine executes scripts override it (the built-in native driver does).

§Errors

Returns the engine’s error of the first statement that fails.

Source

fn query_named( &mut self, sql: &str, params: &[Value], row: &mut dyn FnMut(&[String], &dyn Row), ) -> Result<(), DbError>

SqliteConnection::query, with the result’s column names alongside each row, for callers that surface rows as named objects (day-lite’s JS bridge). A driver that cannot name columns refuses rather than guessing.

§Errors

Returns the engine’s error when the statement fails, or an error from a driver that cannot name columns.

Trait Implementations§

Source§

impl SqliteConnection for Box<dyn SqliteConnection>

Source§

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

Run one statement and return the number of rows it changed. Read more
Source§

fn query( &mut self, sql: &str, params: &[Value], row: &mut dyn FnMut(&dyn Row), ) -> Result<(), DbError>

Run one statement, handing each result row to row. Read more
Source§

fn execute_batch(&mut self, sql: &str) -> Result<(), DbError>

Several statements in one string, no parameters: a DDL script, a migration step (day-lite’s storage speaks this). The default runs the string as one statement; drivers whose engine executes scripts override it (the built-in native driver does). Read more
Source§

fn query_named( &mut self, sql: &str, params: &[Value], row: &mut dyn FnMut(&[String], &dyn Row), ) -> Result<(), DbError>

SqliteConnection::query, with the result’s column names alongside each row, for callers that surface rows as named objects (day-lite’s JS bridge). A driver that cannot name columns refuses rather than guessing. Read more
Source§

fn begin(&mut self) -> Result<(), DbError>

Begin a transaction. Read more
Source§

fn commit(&mut self) -> Result<(), DbError>

Commit the open transaction. Read more
Source§

fn rollback(&mut self) -> Result<(), DbError>

Roll the open transaction back. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SqliteConnection for Box<dyn SqliteConnection>

Source§

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

Source§

fn query( &mut self, sql: &str, params: &[Value], row: &mut dyn FnMut(&dyn Row), ) -> Result<(), DbError>

Source§

fn execute_batch(&mut self, sql: &str) -> Result<(), DbError>

Source§

fn query_named( &mut self, sql: &str, params: &[Value], row: &mut dyn FnMut(&[String], &dyn Row), ) -> Result<(), DbError>

Implementors§