.. _references: ***************** SQL Query Builder ***************** The goal of the SQL Query Builder is to provide a canonical interface to build SQL queries. The QueryBuilder refers to a `dialect` as a variant of the SQL language dependent of the choice of the backend technology. The only supported dialect is the one of `SQLite` but building new dialects shouldn't be too hard. The submodule `sql` contains many standard constructors for SQL languages. See the submodule `sqlite` for a dialect for `SQLite`. Typical usage ------------- Building a Schema ^^^^^^^^^^^^^^^^^ We first import the generic SQL dialect. >>> from networkdisk.sql import sqldialect as dialect The SQL dialect contains pointers towards several subdialects: >>> dialect Dialect(SQL) Each subdialect contains an SQL query builder object. >>> c = dialect.columns.ValueColumn(1) >>> c2 = dialect.columns.AddColumn(c, c) >>> dialect.queries.SelectQuery(columns=c2) SelectQuery >>> fooTable.select_query(columns=("age",)) SelectQuery >>> fooTable.select_query(condition=ageC.gt(18) & ageC.lt(42)) SelectQuery >>> JQ.select_query(columns=("name", "msg"), condition=msgC.neq(dialect.constants.Null)) SelectQuery