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

pub struct SqliteConnectOptions { /* fields omitted */ }
This is supported on crate feature sqlite only.
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().await?;

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.

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.

Log executed statements with the specified level

Log executed statements with a duration above the specified duration at the specified level. Read more

Entirely disables statement logging (both slow and regular).

Formats the value using the given formatter. Read more

Returns the ā€œdefault valueā€ for a type. Read more

Performs the conversion.

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.

Should always be Self

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)

recently added

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.