pub struct TemporaryDatabase { /* private fields */ }Expand description
A temporary SQLite database that is automatically cleaned up on drop.
The database file is created in a temporary directory that is removed when this struct is dropped, ensuring no test artifacts remain.
Implementations§
Source§impl TemporaryDatabase
impl TemporaryDatabase
Sourcepub fn new(name: &str) -> Result<Self>
pub fn new(name: &str) -> Result<Self>
Create a new temporary database with the given name.
The database file will be created as {name}.db in a temporary directory.
The file is touch()ed to ensure it exists on disk.
§Arguments
name- A name for the database (used in the filename)
§Returns
A new TemporaryDatabase instance, or an error if creation fails.
Sourcepub fn with_schema(name: &str, schema: &str) -> Result<Self>
pub fn with_schema(name: &str, schema: &str) -> Result<Self>
Sourcepub fn connection_string(&self) -> String
pub fn connection_string(&self) -> String
Get a connection string suitable for SQLx or other SQLite clients.
Returns a string in the format sqlite:/path/to/database.db
Auto Trait Implementations§
impl Freeze for TemporaryDatabase
impl RefUnwindSafe for TemporaryDatabase
impl Send for TemporaryDatabase
impl Sync for TemporaryDatabase
impl Unpin for TemporaryDatabase
impl UnsafeUnpin for TemporaryDatabase
impl UnwindSafe for TemporaryDatabase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more