pub enum Dialect {
Postgres,
Sqlite,
Mysql,
}Expand description
A database connection capable of executing queries.
All operations are async and take a Cx context for cancellation/timeout support.
Implementations must be Send + Sync for use across async boundaries.
§Transaction Support
Use begin or begin_with to
start transactions. Transactions must be explicitly committed or rolled back.
§Example
ⓘ
// Execute a simple query
let rows = conn.query(&cx, "SELECT * FROM users WHERE id = $1", &[Value::Int(1)]).await?;
// Use a transaction
let mut tx = conn.begin(&cx).await?;
tx.execute(&cx, "INSERT INTO logs (msg) VALUES ($1)", &[Value::Text("action".into())]).await?;
tx.commit(&cx).await?;SQL dialect enumeration for cross-database compatibility.
Variants§
Postgres
PostgreSQL dialect (uses $1, $2 placeholders)
Sqlite
SQLite dialect (uses ?1, ?2 placeholders)
Mysql
MySQL dialect (uses ? placeholders)
Implementations§
Source§impl Dialect
impl Dialect
Sourcepub fn placeholder(self, index: usize) -> String
pub fn placeholder(self, index: usize) -> String
Generate a placeholder for the given parameter index (1-based).
Sourcepub const fn concat_op(self) -> &'static str
pub const fn concat_op(self) -> &'static str
Get the string concatenation operator for this dialect.
Sourcepub const fn supports_ilike(self) -> bool
pub const fn supports_ilike(self) -> bool
Check if this dialect supports ILIKE.
Sourcepub fn quote_identifier(self, name: &str) -> String
pub fn quote_identifier(self, name: &str) -> String
Quote an identifier for this dialect.
Properly escapes embedded quote characters by doubling them:
- For Postgres/SQLite:
"becomes"" - For MySQL:
`becomes``
Trait Implementations§
impl Copy for Dialect
impl Eq for Dialect
impl StructuralPartialEq for Dialect
Auto Trait Implementations§
impl Freeze for Dialect
impl RefUnwindSafe for Dialect
impl Send for Dialect
impl Sync for Dialect
impl Unpin for Dialect
impl UnwindSafe for Dialect
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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).