pub struct RusqliteEngine { /* private fields */ }Expand description
Rusqlite-backed OLTP engine.
Uses a single dedicated write connection for DML/DDL and a round-robin pool of read connections for queries. WAL mode is enabled on startup so readers don’t block the writer.
Implementations§
Source§impl RusqliteEngine
impl RusqliteEngine
Sourcepub async fn new_local(
path: &str,
read_pool_size: usize,
) -> Result<RusqliteEngine, RusqliteOltpError>
pub async fn new_local( path: &str, read_pool_size: usize, ) -> Result<RusqliteEngine, RusqliteOltpError>
Create a new engine backed by a local SQLite database file.
read_pool_size controls how many concurrent read connections are
maintained. Values below 1 are clamped to 1.
Sourcepub async fn new_connection(&self) -> Result<Connection, RusqliteOltpError>
pub async fn new_connection(&self) -> Result<Connection, RusqliteOltpError>
Create a fresh, independent connection to the same database file.
Used to give RusqliteCdcProducer its own connection that doesn’t compete
with application reads/writes.
Sourcepub fn connection(&self) -> Connection
pub fn connection(&self) -> Connection
Returns a clone of the write connection handle. Used by CDC trigger setup/teardown (DDL).
Trait Implementations§
Source§impl OltpEngine for RusqliteEngine
impl OltpEngine for RusqliteEngine
Source§async fn query(
&self,
sql: &str,
params: &[Value],
) -> Result<Vec<RecordBatch>, <RusqliteEngine as OltpEngine>::Error>
async fn query( &self, sql: &str, params: &[Value], ) -> Result<Vec<RecordBatch>, <RusqliteEngine as OltpEngine>::Error>
Execute a read-only SQL query and return the results as Arrow
RecordBatches.
Dispatches to the next connection in the round-robin read pool.
The Arrow schema is inferred from actual cell values (see the
SCHEMA_WARMUP_ROWS constant for the sparse-column strategy).
§Errors
Returns RusqliteOltpError if statement preparation, execution, or
Arrow conversion fails.
Source§async fn execute(
&self,
sql: &str,
params: &[Value],
) -> Result<u64, <RusqliteEngine as OltpEngine>::Error>
async fn execute( &self, sql: &str, params: &[Value], ) -> Result<u64, <RusqliteEngine as OltpEngine>::Error>
Execute a single write statement (INSERT, UPDATE, DELETE, or DDL)
and return the number of rows affected.
Always dispatches to the single dedicated write connection.
§Errors
Returns RusqliteOltpError if the statement fails (e.g., constraint
violation, syntax error, or the database is locked beyond
busy_timeout).
Source§async fn execute_batch(
&self,
statements: &[(String, Vec<Value>)],
) -> Result<(), <RusqliteEngine as OltpEngine>::Error>
async fn execute_batch( &self, statements: &[(String, Vec<Value>)], ) -> Result<(), <RusqliteEngine as OltpEngine>::Error>
Execute a batch of write statements inside a single BEGIN…COMMIT
transaction.
All statements succeed or the entire transaction is rolled back. Dispatches to the dedicated write connection.
§Errors
Returns RusqliteOltpError if any statement fails or the transaction
cannot be committed.
Source§async fn table_exists(
&self,
table_name: &str,
) -> Result<bool, <RusqliteEngine as OltpEngine>::Error>
async fn table_exists( &self, table_name: &str, ) -> Result<bool, <RusqliteEngine as OltpEngine>::Error>
Return true if a table named table_name exists in sqlite_master.
Uses a read-pool connection.
§Errors
Returns RusqliteOltpError if the metadata query fails.
Source§type Error = RusqliteOltpError
type Error = RusqliteOltpError
Auto Trait Implementations§
impl !Freeze for RusqliteEngine
impl RefUnwindSafe for RusqliteEngine
impl Send for RusqliteEngine
impl Sync for RusqliteEngine
impl Unpin for RusqliteEngine
impl UnsafeUnpin for RusqliteEngine
impl UnwindSafe for RusqliteEngine
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more