Struct sqlx::sqlite::SqliteConnectOptions[][src]

pub struct SqliteConnectOptions { /* fields omitted */ }
This is supported on crate feature sqlite only.

Options and flags which can be used to configure a SQLite connection.

A value of SqliteConnectOptions can be parsed from a connection URI, as described by SQLite.

URIDescription
sqlite::memory:Open an in-memory database.
sqlite:data.dbOpen the file data.db in the current directory.
sqlite://data.dbOpen the file data.db in the current directory.
sqlite:///data.dbOpen the file data.db from the root (/) directory.
sqlite://data.db?mode=roOpen the file data.db for read-only access.

Example

use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode};
use std::str::FromStr;

let conn = SqliteConnectOptions::from_str("sqlite://data.db")?
    .journal_mode(SqliteJournalMode::Wal)
    .read_only(true)
    .connect().await?;

Implementations

impl SqliteConnectOptions[src]

pub fn new() -> SqliteConnectOptions[src]

pub fn filename(self, filename: impl AsRef<Path>) -> SqliteConnectOptions[src]

Sets the name of the database file.

pub fn foreign_keys(self, on: bool) -> SqliteConnectOptions[src]

Set the enforcement of foreign key constriants.

By default, this is enabled.

pub fn journal_mode(self, mode: SqliteJournalMode) -> SqliteConnectOptions[src]

Sets the journal mode for the database connection.

The default journal mode is WAL. For most use cases this can be significantly faster but there are disadvantages.

pub fn read_only(self, read_only: bool) -> SqliteConnectOptions[src]

Sets the access mode to open the database for read-only access.

pub fn create_if_missing(self, create: bool) -> SqliteConnectOptions[src]

Sets the access mode to create the database file if the file does not exist.

By default, a new file will not be created if one is not found.

pub fn statement_cache_capacity(self, capacity: usize) -> SqliteConnectOptions[src]

Sets the capacity of the connection's statement cache in a number of stored distinct statements. Caching is handled using LRU, meaning when the amount of queries hits the defined limit, the oldest statement will get dropped.

The default cache capacity is 100 statements.

pub fn busy_timeout(self, timeout: Duration) -> SqliteConnectOptions[src]

Sets a timeout value to wait when the database is locked, before returning a busy timeout error.

The default busy timeout is 5 seconds.

pub fn synchronous(self, synchronous: SqliteSynchronous) -> SqliteConnectOptions[src]

Sets the synchronous setting for the database connection.

The default synchronous settings is FULL. However, if durability is not a concern, then NORMAL is normally all one needs in WAL mode.

Trait Implementations

impl Clone for SqliteConnectOptions[src]

impl ConnectOptions for SqliteConnectOptions[src]

type Connection = SqliteConnection

impl Debug for SqliteConnectOptions[src]

impl Default for SqliteConnectOptions[src]

impl From<SqliteConnectOptions> for AnyConnectOptions[src]

impl FromStr for SqliteConnectOptions[src]

type Err = Error

The associated error which can be returned from parsing.

Auto Trait Implementations

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> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

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

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

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

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>,