Dialect Classes
Each dialect class (PG, MYSQL, SQLITE, ORACLE, MSSQL)
provides access to the builder classes and formatters for that database. The
attributes are the builder classes themselves, so calling e.g. SQL.select()
instantiates the PostgreSQL-specific SELECT builder (PgSelect).
from sqlexpr import PG as SQL
qb = SQL.select() # creates a PgSelect instance
All dialect classes share a common set of builder attributes. Where a dialect
needs specialised behaviour, it overrides the attribute with a subclass — for
example SQL.select is PgSelect (which adds DISTINCT ON, WINDOW, etc.)
while MYSQL.select is the base SqlSelect.
Common Attributes
The following are available on all dialect classes.
|
Create a SELECT query. Returns SqlSelect. |
|
Create an INSERT query. Returns SqlInsert. |
|
Create an UPDATE query. Returns SqlUpdate. |
|
Create a column-list SET clause for UPDATE. Returns SqlColumnList. |
|
Create a DELETE query. Returns SqlDelete. |
|
Create a single condition. Returns SqlTerm. |
|
Combine conditions with AND. Returns SqlAnd. |
|
Combine conditions with OR. Returns SqlOr. |
|
A positional parameter placeholder. Returns SqlValue. |
|
A named parameter placeholder. Returns SqlNamedValue. |
|
Concatenate literal SQL fragments and value objects. Returns SqlCat. |
|
A column reference with an optional alias. Returns SqlColumn. |
|
A Common Table Expression for WITH clauses. Returns SqlCte. |
|
A JOIN clause. Returns SqlJoin. |
|
A set operation (UNION, INTERSECT, EXCEPT). Returns SqlUnion. |
PG
PostgreSQL dialect class. Overrides and additions:
|
SELECT with DISTINCT ON, INTO, WINDOW, FETCH, FOR locking. Returns PgSelect. |
|
INSERT with ON CONFLICT and RETURNING. Returns PgInsert. |
|
UPDATE with ONLY, RETURNING, RETURNING WITH. Returns PgUpdate. |
|
DELETE with ONLY and RETURNING. Returns PgDelete. |
|
CTE with MATERIALIZED support. Returns PgCte. |
|
A named WINDOW definition. Returns PgWindow. |
|
A FOR locking clause (UPDATE, SHARE, etc.). Returns PgForLocking. |
|
CREATE TABLE with PG extensions. Returns SqlCreateTable. |
|
DROP TABLE. Returns SqlDropTable. |
|
CREATE INDEX with PG extensions. Returns SqlCreateIndex. |
|
COPY-based bulk insert. Returns SqlBulkCopy. |
|
Render with |
|
Render with |
MYSQL
MySQL dialect class. Overrides and additions:
|
DELETE with alias and JOIN support. Returns MysqlDelete. |
|
INSERT with IGNORE support. Returns MysqlInsert. |
|
Render with |
|
Render with |
SQLITE
SQLite dialect class. Overrides and additions:
|
INSERT with OR IGNORE support. Returns SqliteInsert. |
|
Render with |
ORACLE
Oracle dialect class. Formatters:
|
Render with |
|
Render with |
MSSQL
Microsoft SQL Server dialect class. Formatters:
|
Render with |