Struct diesel::sqlite::SqliteConnection[][src]

pub struct SqliteConnection { /* fields omitted */ }

Connections for the SQLite backend. Unlike other backends, SQLite supported connection URLs are:

Implementations

impl SqliteConnection[src]

pub fn immediate_transaction<T, E, F>(&mut self, f: F) -> Result<T, E> where
    F: FnOnce(&mut Self) -> Result<T, E>,
    E: From<Error>, 
[src]

Run a transaction with BEGIN IMMEDIATE

This method will return an error if a transaction is already open.

Example

conn.immediate_transaction(|conn| {
    // Do stuff in a transaction
    Ok(())
})

pub fn exclusive_transaction<T, E, F>(&mut self, f: F) -> Result<T, E> where
    F: FnOnce(&mut Self) -> Result<T, E>,
    E: From<Error>, 
[src]

Run a transaction with BEGIN EXCLUSIVE

This method will return an error if a transaction is already open.

Example

conn.exclusive_transaction(|conn| {
    // Do stuff in a transaction
    Ok(())
})

pub fn register_collation<F>(
    &mut self,
    collation_name: &str,
    collation: F
) -> QueryResult<()> where
    F: Fn(&str, &str) -> Ordering + Send + 'static + UnwindSafe
[src]

Register a collation function.

collation must always return the same answer given the same inputs. If collation panics and unwinds the stack, the process is aborted, since it is used across a C FFI boundary, which cannot be unwound across and there is no way to signal failures via the SQLite interface in this case..

If the name is already registered it will be overwritten.

This method will return an error if registering the function fails, either due to an out-of-memory situation or because a collation with that name already exists and is currently being used in parallel by a query.

The collation needs to be specified when creating a table: CREATE TABLE my_table ( str TEXT COLLATE MY_COLLATION ), where MY_COLLATION corresponds to name passed as collation_name.

Example

// sqlite NOCASE only works for ASCII characters,
// this collation allows handling UTF-8 (barring locale differences)
conn.register_collation("RUSTNOCASE", |rhs, lhs| {
    rhs.to_lowercase().cmp(&lhs.to_lowercase())
})

Trait Implementations

impl Connection for SqliteConnection[src]

type Backend = Sqlite

The backend this type connects to

type TransactionManager = AnsiTransactionManager

fn establish(database_url: &str) -> ConnectionResult<Self>[src]

Establish a connection to the database specified by database_url.

See SqliteConnection for supported database_url.

If the database does not exist, this method will try to create a new database and then establish a connection to it.

impl MigrationConnection for SqliteConnection[src]

impl R2D2Connection for SqliteConnection[src]

impl Send for SqliteConnection[src]

impl SimpleConnection for SqliteConnection[src]

impl<Changes, Output> UpdateAndFetchResults<Changes, Output> for SqliteConnection where
    Changes: Copy + Identifiable,
    Changes: AsChangeset<Target = <Changes as HasTable>::Table> + IntoUpdateTarget,
    Changes::Table: FindDsl<Changes::Id>,
    Update<Changes, Changes>: ExecuteDsl<SqliteConnection>,
    Find<Changes::Table, Changes::Id>: LoadQuery<SqliteConnection, Output>,
    <Changes::Table as Table>::AllColumns: ValidGrouping<()>,
    <<Changes::Table as Table>::AllColumns as ValidGrouping<()>>::IsAggregate: MixedAggregates<No, Output = No>, 
[src]

Auto Trait Implementations

impl RefUnwindSafe for SqliteConnection

impl !Sync for SqliteConnection

impl Unpin for SqliteConnection

impl UnwindSafe for SqliteConnection

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoSql for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]