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

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]

This is supported on crate feature sqlite only.

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

This is supported on crate feature sqlite only.

Sets the name of the database file.

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

This is supported on crate feature sqlite only.

Set the enforcement of foreign key constriants.

By default, this is enabled.

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

This is supported on crate feature sqlite only.

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]

This is supported on crate feature sqlite only.

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

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

This is supported on crate feature sqlite only.

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

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

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

This is supported on crate feature sqlite only.

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.

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 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> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

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