pub struct Connection<'a> { /* private fields */ }Expand description
A SQL connection wrapping a Citadel database.
Supports explicit transactions via BEGIN / COMMIT / ROLLBACK. Without BEGIN, each statement runs in auto-commit mode.
Caches parsed SQL statements in an LRU cache keyed by SQL string. Cache entries are invalidated when the schema changes (DDL operations).
Implementations§
Source§impl<'a> Connection<'a>
impl<'a> Connection<'a>
Sourcepub fn execute(&mut self, sql: &str) -> Result<ExecutionResult>
pub fn execute(&mut self, sql: &str) -> Result<ExecutionResult>
Execute a SQL statement. Returns the result.
Sourcepub fn execute_params(
&mut self,
sql: &str,
params: &[Value],
) -> Result<ExecutionResult>
pub fn execute_params( &mut self, sql: &str, params: &[Value], ) -> Result<ExecutionResult>
Execute a SQL statement with positional parameters ($1, $2, …).
Sourcepub fn query(&mut self, sql: &str) -> Result<QueryResult>
pub fn query(&mut self, sql: &str) -> Result<QueryResult>
Execute a SQL query and return the result set.
Sourcepub fn query_params(
&mut self,
sql: &str,
params: &[Value],
) -> Result<QueryResult>
pub fn query_params( &mut self, sql: &str, params: &[Value], ) -> Result<QueryResult>
Execute a SQL query with positional parameters ($1, $2, …).
Sourcepub fn in_transaction(&self) -> bool
pub fn in_transaction(&self) -> bool
Returns true if an explicit transaction is active (BEGIN was issued).
Sourcepub fn table_schema(&self, name: &str) -> Option<&TableSchema>
pub fn table_schema(&self, name: &str) -> Option<&TableSchema>
Get the schema for a named table.
Sourcepub fn refresh_schema(&mut self) -> Result<()>
pub fn refresh_schema(&mut self) -> Result<()>
Reload schemas from the database.
Auto Trait Implementations§
impl<'a> Freeze for Connection<'a>
impl<'a> !RefUnwindSafe for Connection<'a>
impl<'a> Send for Connection<'a>
impl<'a> Sync for Connection<'a>
impl<'a> Unpin for Connection<'a>
impl<'a> UnsafeUnpin for Connection<'a>
impl<'a> !UnwindSafe for Connection<'a>
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