pub struct FrankenConnection { /* private fields */ }Expand description
A SQLite connection backed by FrankenSQLite (pure Rust).
Implements sqlmodel_core::Connection and provides sync helper methods
(execute_raw, query_sync, execute_sync, etc.) matching the
SqliteConnection API for drop-in replacement.
Implementations§
Source§impl FrankenConnection
impl FrankenConnection
Sourcepub fn open(path: impl Into<String>) -> Result<Self, Error>
pub fn open(path: impl Into<String>) -> Result<Self, Error>
Open a connection with the given path.
Use ":memory:" for an in-memory database, or a file path for
persistent storage.
Sourcepub fn open_memory() -> Result<Self, Error>
pub fn open_memory() -> Result<Self, Error>
Open an in-memory database.
Sourcepub fn close_sync(self) -> Result<(), Error>
pub fn close_sync(self) -> Result<(), Error>
Close the underlying frankensqlite connection synchronously.
Sourcepub fn execute_raw(&self, sql: &str) -> Result<(), Error>
pub fn execute_raw(&self, sql: &str) -> Result<(), Error>
Execute SQL directly without parameter binding (for DDL, PRAGMAs, etc.)
Sourcepub fn query_sync(&self, sql: &str, params: &[Value]) -> Result<Vec<Row>, Error>
pub fn query_sync(&self, sql: &str, params: &[Value]) -> Result<Vec<Row>, Error>
Prepare and execute a query synchronously, returning all rows.
Sourcepub fn execute_sync(&self, sql: &str, params: &[Value]) -> Result<u64, Error>
pub fn execute_sync(&self, sql: &str, params: &[Value]) -> Result<u64, Error>
Prepare and execute a statement synchronously, returning rows affected.
Sourcepub fn last_insert_rowid(&self) -> i64
pub fn last_insert_rowid(&self) -> i64
Get the last inserted rowid.
Trait Implementations§
Source§impl Connection for FrankenConnection
impl Connection for FrankenConnection
Source§type Tx<'conn> = FrankenTransaction<'conn>
where
Self: 'conn
type Tx<'conn> = FrankenTransaction<'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.
impl Send for FrankenConnection
impl Sync for FrankenConnection
Auto Trait Implementations§
impl Freeze for FrankenConnection
impl RefUnwindSafe for FrankenConnection
impl Unpin for FrankenConnection
impl UnsafeUnpin for FrankenConnection
impl UnwindSafe for FrankenConnection
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).