pub struct Tx<'db> { /* private fields */ }Expand description
A synchronous transaction bound to its checked-out connection and thread.
Tx is intentionally not Send: SQLite transaction work and rollback
must remain on the checkout owner thread. Use the async handle to schedule
database work instead of moving a synchronous transaction between threads.
An uncommitted transaction is rolled back when dropped.
With the live feature, PRAGMA statements conservatively accumulate full
invalidation, including read-only forms.
Implementations§
Source§impl Tx<'_>
impl Tx<'_>
Sourcepub fn query_optional<T: FromRow, P: Params>(
&self,
sql: &str,
params: P,
) -> Result<Option<T>>
pub fn query_optional<T: FromRow, P: Params>( &self, sql: &str, params: P, ) -> Result<Option<T>>
0~1건 조회
Sourcepub fn query_scalar<T: FromSql, P: Params>(
&self,
sql: &str,
params: P,
) -> Result<T>
pub fn query_scalar<T: FromSql, P: Params>( &self, sql: &str, params: P, ) -> Result<T>
스칼라 1건 조회
Sourcepub fn query_all<T: FromRow, P: Params>(
&self,
sql: &str,
params: P,
) -> Result<Vec<T>>
pub fn query_all<T: FromRow, P: Params>( &self, sql: &str, params: P, ) -> Result<Vec<T>>
N건 조회
Sourcepub fn execute_batch(&self, sql: &str) -> Result<()>
pub fn execute_batch(&self, sql: &str) -> Result<()>
배치 실행 — 여러 문장 세미콜론 구분 (마이그레이션·일괄 write용).
Batch writes participate in invalidation (M-2): affected tables are collected per statement and emitted after the transaction commits. A statement that cannot be parsed degrades to a conservative full invalidation.
Trait Implementations§
Source§impl SqlContext for Tx<'_>
impl SqlContext for Tx<'_>
Source§fn ctx_transaction<R>(&self, f: impl FnOnce(&Tx<'_>) -> Result<R>) -> Result<R>
fn ctx_transaction<R>(&self, f: impl FnOnce(&Tx<'_>) -> Result<R>) -> Result<R>
tx-바운드 트랜잭션 = 중첩 savepoint (명세 §5.9)