pub struct SqliteConnection { /* private fields */ }Expand description
A connection to a SQLite database.
This is a thread-safe wrapper around a SQLite database handle.
Implementations§
Source§impl SqliteConnection
impl SqliteConnection
Sourcepub fn open(config: &SqliteConfig) -> Result<Self, Error>
pub fn open(config: &SqliteConfig) -> Result<Self, Error>
Open a new SQLite connection with the given configuration.
Sourcepub fn open_memory() -> Result<Self, Error>
pub fn open_memory() -> Result<Self, Error>
Open an in-memory database.
Sourcepub fn execute_raw(&self, sql: &str) -> Result<(), Error>
pub fn execute_raw(&self, sql: &str) -> Result<(), Error>
Execute SQL directly without preparing (for DDL, etc.)
Sourcepub fn backup_to_path(&self, dest_path: impl AsRef<str>) -> Result<(), Error>
pub fn backup_to_path(&self, dest_path: impl AsRef<str>) -> Result<(), Error>
Backup the current database to a destination path using the SQLite backup API.
This opens (or creates) the destination database and performs an online backup
from this connection’s main database into the destination’s main database.
Sourcepub fn backup_to_connection(&self, dest: &SqliteConnection) -> Result<(), Error>
pub fn backup_to_connection(&self, dest: &SqliteConnection) -> Result<(), Error>
Backup the current database to another open SQLite connection.
Sourcepub fn last_insert_rowid(&self) -> i64
pub fn last_insert_rowid(&self) -> i64
Get the last insert rowid.
Source§impl SqliteConnection
impl SqliteConnection
Sourcepub fn emit_busy_waiting(&self, _elapsed_secs: f64)
pub fn emit_busy_waiting(&self, _elapsed_secs: f64)
No-op when console feature is disabled.
Sourcepub fn emit_checkpoint_progress(&self, _pages_done: u32, _pages_total: u32)
pub fn emit_checkpoint_progress(&self, _pages_done: u32, _pages_total: u32)
No-op when console feature is disabled.
Trait Implementations§
Source§impl Connection for SqliteConnection
impl Connection for SqliteConnection
Source§type Tx<'conn> = SqliteTransaction<'conn>
where
Self: 'conn
type Tx<'conn> = SqliteTransaction<'conn> where Self: 'conn
The transaction type returned by this connection.
Source§fn query(
&self,
_cx: &Cx,
sql: &str,
params: &[Value],
) -> impl Future<Output = Outcome<Vec<Row>, Error>> + Send
fn query( &self, _cx: &Cx, sql: &str, params: &[Value], ) -> impl Future<Output = Outcome<Vec<Row>, Error>> + Send
Execute a query and return all rows.
Source§fn query_one(
&self,
_cx: &Cx,
sql: &str,
params: &[Value],
) -> impl Future<Output = Outcome<Option<Row>, Error>> + Send
fn query_one( &self, _cx: &Cx, sql: &str, params: &[Value], ) -> impl Future<Output = Outcome<Option<Row>, Error>> + Send
Execute a query and return the first row, if any.
Source§fn execute(
&self,
_cx: &Cx,
sql: &str,
params: &[Value],
) -> impl Future<Output = Outcome<u64, Error>> + Send
fn execute( &self, _cx: &Cx, sql: &str, params: &[Value], ) -> impl Future<Output = Outcome<u64, Error>> + Send
Execute a statement (INSERT, UPDATE, DELETE) and return rows affected.
Source§fn insert(
&self,
_cx: &Cx,
sql: &str,
params: &[Value],
) -> impl Future<Output = Outcome<i64, Error>> + Send
fn insert( &self, _cx: &Cx, sql: &str, params: &[Value], ) -> impl Future<Output = Outcome<i64, Error>> + Send
Execute an INSERT and return the last inserted ID. Read more
Source§fn batch(
&self,
_cx: &Cx,
statements: &[(String, Vec<Value>)],
) -> impl Future<Output = Outcome<Vec<u64>, Error>> + Send
fn batch( &self, _cx: &Cx, statements: &[(String, Vec<Value>)], ) -> impl Future<Output = Outcome<Vec<u64>, Error>> + Send
Execute multiple statements in a batch. Read more
Source§fn begin(
&self,
cx: &Cx,
) -> impl Future<Output = Outcome<Self::Tx<'_>, Error>> + Send
fn begin( &self, cx: &Cx, ) -> impl Future<Output = Outcome<Self::Tx<'_>, Error>> + Send
Begin a transaction with default isolation level (ReadCommitted).
Source§fn begin_with(
&self,
_cx: &Cx,
isolation: IsolationLevel,
) -> impl Future<Output = Outcome<Self::Tx<'_>, Error>> + Send
fn begin_with( &self, _cx: &Cx, isolation: IsolationLevel, ) -> impl Future<Output = Outcome<Self::Tx<'_>, Error>> + Send
Begin a transaction with a specific isolation level.
Source§fn prepare(
&self,
_cx: &Cx,
sql: &str,
) -> impl Future<Output = Outcome<PreparedStatement, Error>> + Send
fn prepare( &self, _cx: &Cx, sql: &str, ) -> impl Future<Output = Outcome<PreparedStatement, Error>> + Send
Prepare a statement for repeated execution. Read more
Source§fn query_prepared(
&self,
cx: &Cx,
stmt: &PreparedStatement,
params: &[Value],
) -> impl Future<Output = Outcome<Vec<Row>, Error>> + Send
fn query_prepared( &self, cx: &Cx, stmt: &PreparedStatement, params: &[Value], ) -> impl Future<Output = Outcome<Vec<Row>, Error>> + Send
Execute a prepared statement and return all rows.
Source§fn execute_prepared(
&self,
cx: &Cx,
stmt: &PreparedStatement,
params: &[Value],
) -> impl Future<Output = Outcome<u64, Error>> + Send
fn execute_prepared( &self, cx: &Cx, stmt: &PreparedStatement, params: &[Value], ) -> impl Future<Output = Outcome<u64, Error>> + Send
Execute a prepared statement (INSERT, UPDATE, DELETE) and return rows affected.
Source§impl Drop for SqliteConnection
impl Drop for SqliteConnection
impl Send for SqliteConnection
impl Sync for SqliteConnection
Auto Trait Implementations§
impl !Freeze for SqliteConnection
impl RefUnwindSafe for SqliteConnection
impl Unpin for SqliteConnection
impl UnsafeUnpin for SqliteConnection
impl UnwindSafe for SqliteConnection
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).