Struct sqlx::sqlite::SqliteConnectOptions [−][src]
pub struct SqliteConnectOptions { /* fields omitted */ }
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.
URI | Description |
---|---|
sqlite::memory: | Open an in-memory database. |
sqlite:data.db | Open the file data.db in the current directory. |
sqlite://data.db | Open the file data.db in the current directory. |
sqlite:///data.db | Open the file data.db from the root (/ ) directory. |
sqlite://data.db?mode=ro | Open 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
type Connection = SqliteConnection
pub fn connect(
&self
) -> Pin<Box<dyn Future<Output = Result<<SqliteConnectOptions as ConnectOptions>::Connection, Error>> + Send, Global>> where
<SqliteConnectOptions as ConnectOptions>::Connection: Sized,
pub fn connect(
&self
) -> Pin<Box<dyn Future<Output = Result<<SqliteConnectOptions as ConnectOptions>::Connection, Error>> + Send, Global>> where
<SqliteConnectOptions as ConnectOptions>::Connection: Sized,
Establish a new database connection with the options specified by self
.
Log executed statements with the specified level
pub fn log_slow_statements(
&mut self,
level: LevelFilter,
duration: Duration
) -> &mut SqliteConnectOptions
pub fn log_slow_statements(
&mut self,
level: LevelFilter,
duration: Duration
) -> &mut SqliteConnectOptions
Log executed statements with a duration above the specified duration
at the specified level
. Read more
Entirely disables statement logging (both slow and regular).
Returns the ādefault valueā for a type. Read more
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for SqliteConnectOptions
impl Send for SqliteConnectOptions
impl Sync for SqliteConnectOptions
impl Unpin for SqliteConnectOptions
impl UnwindSafe for SqliteConnectOptions
Blanket Implementations
Mutably borrows from an owned value. Read more