Define the base components of SQL expression trees.
Join a list of clauses together by the AND operator.
The & operator can be used as well.
Return BETWEEN predicate clause.
Equivalent of SQL clausetest BETWEEN clauseleft AND clauseright.
This is better called off a ColumnElement directly, i.e.:
column.between(value1, value2)
Create a bind parameter clause with the given key.
SQL CASE statement.
return CAST function CAST(clause AS totype)
Use with a sqlalchemy.types.TypeEngine object, i.e cast(table.c.unit_price * table.c.qty, Numeric(10,4)) or cast(table.c.timestamp, DATE)
Return a textual column clause, relative to a table.
This is also the primitive version of a schema.Column which is a subclass.
Return a DELETE clause element.
This can also be called from a table directly via the table's delete() method.
Return an INSERT clause element.
This can also be called from a table directly via the table's insert() method.
If both values and compile-time bind parameters are present, the compile-time bind parameters override the information specified within values on a per-key basis.
The keys within values can be either Column objects or their string identifiers. Each key may reference one of:
If a SELECT statement is specified which references this INSERT statement's table, the statement will be correlated against the INSERT statement.
Return a JOIN clause element (regular inner join).
To chain joins together, use the resulting Join object's join() or outerjoin() methods.
Return a literal clause, bound to a bind parameter.
Literal clauses are created automatically when used as the right-hand side of a boolean or math operation against a column object. Use this function when a literal is needed on the left-hand side (and optionally on the right as well).
The optional type parameter is a sqlalchemy.types.TypeEngine object which indicates bind-parameter and result-set translation for this literal.
Return a textual column clause with the literal flag set.
This column will not be quoted.
Return a negation of the given clause, i.e. NOT(clause).
The ~ operator can be used as well.
Join a list of clauses together by the OR operator.
The | operator can be used as well.
Return an OUTER JOIN clause element.
To chain joins together, use the resulting Join object's join() or outerjoin() methods.
Returns a SELECT clause element.
This can also be called via the table's select() method.
Return a table clause.
This is a primitive version of the schema.Table object, which is a subclass of this object.
Create literal text to be inserted into a query.
When constructing a query from a select(), update(), insert() or delete(), using plain strings for argument values will usually result in text objects being created automatically. Use this function when creating textual clauses outside of other ClauseElement objects, or optionally wherever plain text is to be used.
Arguments include:
Return an UPDATE clause element.
This can also be called from a table directly via the table's update() method.
If both values and compile-time bind parameters are present, the compile-time bind parameters override the information specified within values on a per-key basis.
The keys within values can be either Column objects or their string identifiers. Each key may reference one of:
If a SELECT statement is specified which references this UPDATE statement's table, the statement will be correlated against the UPDATE statement.
Represent the behavior of a particular database.
Used by Compiled objects.
Base class for elements of a programmatically constructed SQL expression.
Compare this ClauseElement to the given ClauseElement.
Subclasses should override the default behavior, which is a straight identity comparison.
Compile this SQL expression.
Uses the given Compiler, or the given AbstractDialect or Engine to create a Compiler. If no compiler arguments are given, tries to use the underlying Engine this ClauseElement is bound to to create a Compiler, if any.
Finally, if there is no bound Engine, uses an ANSIDialect to create a default Compiler.
parameters is a dictionary representing the default bind parameters to be used with the statement. If parameters is a list, it is assumed to be a list of dictionaries and the first dictionary in the list is used with which to compile against.
The bind parameters can in some cases determine the output of the compilation, such as for UPDATE and INSERT statements the bind parameters that are present determine the SET and VALUES clause of those statements.
Return a copy of this ClauseElement, if this ClauseElement contains other ClauseElements.
If this ClauseElement is not a container, it should return self. This is used to create copies of expression trees that still reference the same leaf nodes. The new structure can then be restructured without affecting the original.
Attempts to locate a Engine within this ClauseElement structure, or returns None if none found.
return immediate child elements of this ClauseElement.
this is used for visit traversal.
**kwargs may contain flags that change the collection that is returned, for example to return a subset of items in order to cut down on larger traversals, or to return child items from a different context (such as schema-level collections instead of clause-level).
Compile and execute this ClauseElement, returning the result's scalar representation.
Return True if this clause element represents a complete executable statement.
Represent a dictionary/iterator of bind parameter key names/values.
Tracks the original BindParam objects as well as the keys/position of each parameter, and can return parameters as a dictionary or a list. Will process parameter values according to the TypeEngine objects present in the BindParams.
Return the given parameter as it was originally placed in this ClauseParameters object, without any Type conversion.
A class that knows how to traverse and visit ClauseElements.
Each ClauseElement's accept_visitor() method will call a corresponding visit_XXXX() method here. Traversal of a hierarchy of ClauseElements is achieved via the traverse() method, which is passed the lead ClauseElement.
By default, ClauseVisitor traverses all elements fully. Options can be specified at the class level via the __traverse_options__ dictionary which will be passed to the get_children() method of each ClauseElement; these options can indicate modifications to the set of elements returned, such as to not return column collections (column_collections=False) or to return Schema-level items (schema_visitor=True).
An ordered dictionary that stores a list of ColumnElement instances.
Overrides the __eq__() method to produce SQL clauses between sets of correlated columns.
Add a column to this collection.
The key attribute of the column will be used as the hash key for this dictionary.
Represent a column element within the list of a Selectable's columns.
A ColumnElement can either be directly associated with a TableClause, or a free-standing textual column with no table, or is a proxy column, indicating it is placed on a Selectable such as an Alias or Select statement and ultimately corresponds to a TableClause-attached column (or in the case of a CompositeSelect, a proxy ColumnElement may correspond to several TableClause-attached columns).
Columns accessor which just returns self, to provide compatibility with Selectable objects.
Foreign key accessor. Points to a list of ForeignKey objects which represents a Foreign Key placed on this column's ultimate ancestor.
A Set containing TableClause-bound, non-proxied ColumnElements for which this ColumnElement is a proxy. In all cases except for a column proxied from a Union (i.e. CompoundSelect), this set will be just one element.
Primary key flag. Indicates if this Column represents part or whole of a primary key.
Return True if the given ColumnElement has a common ancestor to this ColumnElement.
Represent a compiled SQL expression.
The __str__ method of the Compiled object should produce the actual text of the statement. Compiled objects are specific to their underlying database dialect, and also may or may not be specific to the columns referenced within a particular set of bind parameters. In no case should the Compiled object be dependent on the actual values of those bind parameters, even though it may reference those values as defaults.
Construct a new Compiled object.
Return the bind params for this compiled object.
Will start with the default parameters specified when this Compiled object was first constructed, and will override those values with those sent via **params, which are key/value pairs. Each key should match one of the _BindParamClause objects compiled into this object; either the key or shortname property of the _BindParamClause.
Execute this compiled object and return the result's scalar value.
Interface representing a "thing that can produce Compiled objects and execute them".
Return a Compiled object for the given statement and parameters.
Represent an element that can be used within the FROM clause of a SELECT statement.
Given a ColumnElement, return the exported ColumnElement object from this Selectable which corresponds to that original Column via a common anscestor column.
True if the name of this FromClause may be prepended to a column in a generated SQL statement.
A dictionary mapping an original Table-bound column to a proxied column in this FromClause.
Create a Select out of this Join clause and return an Alias of it.
The Select is not correlating.
Create a Select from this Join.
Represent a SELECT statement, with appendable clauses, as well as the ability to execute itself and return a result set.
Given a FROM object, correlate this SELECT statement to it.
This basically means the given from object will not come out in this select statement's FROM clause when printed.