Struct cdbc_sqlite::SqliteConnectOptions[][src]

pub struct SqliteConnectOptions {
    pub filename: Cow<'static, Path>,
    pub in_memory: bool,
    pub read_only: bool,
    pub create_if_missing: bool,
    pub shared_cache: bool,
    pub statement_cache_capacity: usize,
    pub busy_timeout: Duration,
    pub immutable: bool,
    pub pragmas: IndexMap<Cow<'static, str>, Cow<'static, str>>,
    pub serialized: bool,
}
Expand description

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()?;

Fields

filename: Cow<'static, Path>in_memory: boolread_only: boolcreate_if_missing: boolshared_cache: boolstatement_cache_capacity: usizebusy_timeout: Durationimmutable: boolpragmas: IndexMap<Cow<'static, str>, Cow<'static, str>>serialized: bool

Implementations

Sets the name of the database file.

Set the enforcement of foreign key constriants.

By default, this is enabled.

Set the SQLITE_OPEN_SHAREDCACHE flag.

By default, this is disabled.

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.

Sets the locking mode for the database connection.

The default locking mode is NORMAL.

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

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.

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.

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

The default busy timeout is 5 seconds.

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.

Sets the auto_vacuum setting for the database connection.

The default auto_vacuum setting is NONE.

Sets the page_size setting for the database connection.

The default page_size setting is 4096.

Sets custom initial pragma for the database connection.

Sets the threading mode for the database connection.

The default setting is false corersponding to using OPEN_NOMUTEX, if true then OPEN_FULLMUTEX.

See open for more details.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Establish a new database connection with the options specified by self.

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.