pub struct SqlxSqliteConnection { /* private fields */ }Trait Implementations§
Source§impl Connection for SqlxSqliteConnection
impl Connection for SqlxSqliteConnection
Source§fn execute_with_params<'a>(
&'a mut self,
sql: &'a str,
params: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'a>>
fn execute_with_params<'a>( &'a mut self, sql: &'a str, params: &'a [Value], ) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'a>>
SQLite 参数绑定执行(INSERT/UPDATE/DELETE)
使用 sqlx prepared statement 绑定参数,避免 SQL 注入与字符串转义开销。
对 Value::Bool/I8..=I64/U8..=U64/F32/F64/String/Bytes 直接 bind;
其他类型(Date/DateTime/Json/Array/Object)回退为 to_string() 后以 TEXT 绑定。
Source§fn query_with_params<'a>(
&'a mut self,
sql: &'a str,
params: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<QueryRows, DbError>> + Send + 'a>>
fn query_with_params<'a>( &'a mut self, sql: &'a str, params: &'a [Value], ) -> Pin<Box<dyn Future<Output = Result<QueryRows, DbError>> + Send + 'a>>
SQLite 参数绑定查询(SELECT,HashMap 映射)
使用 sqlx prepared statement 绑定参数,结果按预解析 ColType 解码为
HashMap<String, Value>。与 query 的区别仅在于参数绑定路径。
Source§fn query_values<'a>(
&'a mut self,
sql: &'a str,
) -> Pin<Box<dyn Future<Output = Result<QueryValues, DbError>> + Send + 'a>>
fn query_values<'a>( &'a mut self, sql: &'a str, ) -> Pin<Box<dyn Future<Output = Result<QueryValues, DbError>> + Send + 'a>>
SQLite 位置式查询(SELECT,无参数)
绕过 HashMap<String, Value> 行映射,返回 (列名列表, 按列序号的值矩阵)。
列名与 ColType 仅 to_string/解析一次,后续行复用;每行值按列序号直接 Vec::push,
无哈希计算与字符串克隆。适用于 SELECT ALL 大结果集场景。
Source§fn query_values_with_params<'a>(
&'a mut self,
sql: &'a str,
params: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<QueryValues, DbError>> + Send + 'a>>
fn query_values_with_params<'a>( &'a mut self, sql: &'a str, params: &'a [Value], ) -> Pin<Box<dyn Future<Output = Result<QueryValues, DbError>> + Send + 'a>>
SQLite 参数绑定位置式查询(SELECT)
叠加 prepared statement + 位置式映射 + ColType 预解析三重优化。
Source§fn query_stream<'a>(
&'a mut self,
sql: &'a str,
) -> Pin<Box<dyn Stream<Item = Result<HashMap<String, Value>, DbError>> + Send + 'a>>
fn query_stream<'a>( &'a mut self, sql: &'a str, ) -> Pin<Box<dyn Stream<Item = Result<HashMap<String, Value>, DbError>> + Send + 'a>>
SQLite 流式查询:逐行返回结果,避免大结果集 fetch_all 内存峰值
使用 sqlx::query::fetch 获取行流,逐行映射为 HashMap<String, Value>。
流正常消费完毕后连接归还 self.conn;若提前 drop 流,连接通过
PoolConnection::drop 归还到 sqlx 池,但 self.conn 变为 None。
fn execute<'a>( &'a mut self, sql: &'a str, ) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'a>>
fn query<'a>( &'a mut self, sql: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>, DbError>> + Send + 'a>>
fn begin_transaction<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
fn commit<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
fn rollback<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
fn is_connected(&self) -> bool
fn ping<'a>(&'a mut self) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>
fn close<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
Source§fn in_transaction(&self) -> bool
fn in_transaction(&self) -> bool
Source§impl Drop for SqlxSqliteConnection
impl Drop for SqlxSqliteConnection
Auto Trait Implementations§
impl !RefUnwindSafe for SqlxSqliteConnection
impl !UnwindSafe for SqlxSqliteConnection
impl Freeze for SqlxSqliteConnection
impl Send for SqlxSqliteConnection
impl Sync for SqlxSqliteConnection
impl Unpin for SqlxSqliteConnection
impl UnsafeUnpin for SqlxSqliteConnection
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