pub struct Prepare { /* private fields */ }
Expand description
Prepare is used to open a database from a file or in memory.
Implementations§
Source§impl Prepare
impl Prepare
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.
We currently don’t check that the schema is not modified between transactions. So if that happens then the subsequent queries might fail.
Sourcepub fn open_in_memory() -> Self
pub fn open_in_memory() -> Self
Creates a new empty database in memory.
Sourcepub fn create_db_sql<S: Schema>(self, sql: &[&str]) -> Option<Migrator<S>>
pub fn create_db_sql<S: Schema>(self, sql: &[&str]) -> Option<Migrator<S>>
Execute a raw sql statement if the database was just created.
The sql code is executed after creating the empty database.
Returns None if the database schema is older than S
.
This function will panic if the resulting schema is different, but the version matches.
Sourcepub fn create_db_empty<S: Schema>(self) -> Option<Migrator<S>>
pub fn create_db_empty<S: Schema>(self) -> Option<Migrator<S>>
Create empty tables based on the schema if the database was just created.
Returns None if the database schema is older than S
.
This function will panic if the resulting schema is different, but the version matches.