pub struct Config {
pub synchronous: Synchronous,
pub foreign_keys: ForeignKeys,
/* private fields */
}Expand description
Config is used to open a database from a file or in memory.
This is the first step in the Config -> [Migrator] -> [Database] chain to get a [Database] instance.
§Sqlite config
Sqlite is configured to be in WAL mode.
The effect of this mode is that there can be any number of readers with one concurrent writer.
What is nice about this is that a &crate::Transaction can always be made immediately.
Making a &mutcrate::Transaction has to wait until all other &mutcrate::Transactions are finished.
Fields§
§synchronous: SynchronousConfigure how often SQLite will synchronize the database to disk.
The default is Synchronous::Full.
foreign_keys: ForeignKeysConfigure how foreign keys should be checked.
Implementations§
Source§impl Config
impl Config
Sourcepub fn open(p: impl AsRef<Path>) -> Self
pub fn open(p: impl AsRef<Path>) -> Self
Open a database that is stored in a file. Creates the database if it does not exist.
Opening the same database multiple times at the same time is fine, as long as they migrate to or use the same schema. All locking is done by sqlite, so connections can even be made using different client implementations.
Sourcepub fn open_in_memory() -> Self
pub fn open_in_memory() -> Self
Creates a new empty database in memory.