pub enum Dialect {
Postgres,
Sqlite,
Mysql,
}Expand description
SQL dialect for generating dialect-specific SQL.
Re-exported from sqlmodel_core to ensure consistency across the ecosystem.
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``