class ColumnClause(roles.DDLReferredColumnRole, roles.LabeledColumnExprRole, roles.StrAsPlainColumnRole, Immutable, NamedColumn):
Known subclasses: sqlalchemy.sql.schema.Column
Represents a column expression from any textual string.
The .ColumnClause
, a lightweight analogue to the
_schema.Column
class, is typically invoked using the
_expression.column
function, as in:
from sqlalchemy import column id, name = column("id"), column("name") stmt = select(id, name).select_from("user")
The above statement would produce SQL like:
SELECT id, name FROM user
.ColumnClause
is the immediate superclass of the schema-specific
_schema.Column
object. While the _schema.Column
class has all the
same capabilities as .ColumnClause
, the .ColumnClause
class is usable by itself in those cases where behavioral requirements
are limited to simple SQL expression generation. The object has none of
the associations with schema-level metadata or with execution-time
behavior that _schema.Column
does,
so in that sense is a "lightweight"
version of _schema.Column
.
Full details on .ColumnClause
usage is at
_expression.column
.
See Also
_expression.column
_schema.Column
Method | __init__ |
Produce a .ColumnClause object. |
Method | _clone |
Create a shallow copy of this ClauseElement. |
Method | _compare_name_for_result |
Return True if the given column element compares to this one when targeting within a result row. |
Method | _from_objects |
Undocumented |
Method | _gen_tq_label |
generate table-qualified label |
Method | _make_proxy |
Create a new _expression.ColumnElement representing this _expression.ColumnElement as it appears in the select list of a descending selectable. |
Method | _render_label_in_columns_clause |
No summary |
Method | get_children |
Return immediate child .visitors.Traversible elements of this .visitors.Traversible . |
Class Variable | __visit_name__ |
Undocumented |
Class Variable | _is_multiparam_column |
Undocumented |
Class Variable | _traverse_internals |
Undocumented |
Class Variable | default |
Undocumented |
Class Variable | onupdate |
Undocumented |
Class Variable | server_default |
Undocumented |
Class Variable | server_onupdate |
Undocumented |
Instance Variable | is_literal |
Undocumented |
Instance Variable | key |
The 'key' that in some circumstances refers to this object in a Python namespace. |
Instance Variable | name |
Undocumented |
Instance Variable | table |
Undocumented |
Instance Variable | type |
Undocumented |
Property | _ddl_label |
Undocumented |
Property | entity_namespace |
Undocumented |
Inherited from DDLReferredColumnRole
:
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via DDLReferredColumnRole
, DDLConstraintColumnRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from ExpressionElementRole
(via LabeledColumnExprRole
):
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via LabeledColumnExprRole
, ExpressionElementRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from StrAsPlainColumnRole
:
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via StrAsPlainColumnRole
, ColumnArgumentRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from Immutable
:
Method | _copy_internals |
Undocumented |
Method | params |
Undocumented |
Method | unique_params |
Undocumented |
Class Variable | _is_immutable |
Undocumented |
Inherited from NamedColumn
:
Method | _bind_param |
Undocumented |
Method | _non_anon_label |
the 'name' that naturally applies this element when rendered in SQL. |
Method | _tq_key_label |
table qualified label based on column key. |
Method | _tq_label |
table qualified label based on column name. |
Property | description |
Undocumented |
Inherited from ColumnElement
(via NamedColumn
):
Method | cast |
Produce a type cast, i.e. CAST(<expression> AS <type>). |
Method | label |
Produce a column label, i.e. <columnname> AS <name>. |
Method | operate |
Operate on an argument. |
Method | reverse_operate |
Reverse operate on an argument. |
Method | self_group |
Apply a 'grouping' to this _expression.ClauseElement . |
Method | shares_lineage |
Return True if the given _expression.ColumnElement has a common ancestor to this _expression.ColumnElement . |
Class Variable | foreign_keys |
Undocumented |
Class Variable | primary_key |
Undocumented |
Method | __getattr__ |
Undocumented |
Method | _anon_label |
Undocumented |
Method | _dedupe_anon_label_idx |
label to apply to a column that is anon labeled, but repeated in the SELECT, so that we have to make an "extra anon" label that disambiguates it from the previous appearance. |
Method | _dedupe_anon_tq_label_idx |
Undocumented |
Method | _expression_label |
a suggested label to use in the case that the column has no name, which should be used if possible as the explicit 'AS <label>' where this expression would normally have an anon label. |
Method | _negate |
Undocumented |
Method | _proxy_key |
Undocumented |
Method | _uncached_proxy_set |
An 'uncached' version of proxy set. |
Method | comparator |
Undocumented |
Class Variable | _allow_label_resolve |
A flag that can be flipped to prevent a column from being resolvable by string label name. |
Class Variable | _alt_names |
Undocumented |
Class Variable | _is_implicitly_boolean |
Undocumented |
Class Variable | _proxies |
Undocumented |
Property | _anon_key_label |
Provides a constant 'anonymous key label' for this ColumnElement. |
Property | _anon_name_label |
Provides a constant 'anonymous label' for this ColumnElement. |
Property | _anon_tq_key_label |
Undocumented |
Property | _anon_tq_label |
Undocumented |
Property | _key_label |
legacy; renamed to _tq_key_label |
Property | _label |
legacy; renamed to _tq_label |
Property | _select_iterable |
Undocumented |
Property | anon_key_label |
Undocumented |
Property | anon_label |
Undocumented |
Property | base_columns |
Undocumented |
Property | expression |
Return a column expression. |
Property | proxy_set |
Undocumented |
Inherited from ColumnArgumentOrKeyRole
(via NamedColumn
, ColumnElement
):
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from StatementOptionRole
(via NamedColumn
, ColumnElement
):
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, StatementOptionRole
, StructuralRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from WhereHavingRole
(via NamedColumn
, ColumnElement
):
Class Variable | _role_name |
Undocumented |
Inherited from AllowsLambdaRole
(via NamedColumn
, ColumnElement
, WhereHavingRole
, OnClauseRole
):
Class Variable | allows_lambda |
Undocumented |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, WhereHavingRole
, OnClauseRole
, StructuralRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from BinaryElementRole
(via NamedColumn
, ColumnElement
):
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, BinaryElementRole
, ExpressionElementRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from OrderByRole
(via NamedColumn
, ColumnElement
):
Class Variable | _role_name |
Undocumented |
Inherited from AllowsLambdaRole
(via NamedColumn
, ColumnElement
, OrderByRole
):
Class Variable | allows_lambda |
Undocumented |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, OrderByRole
, ByOfRole
, ColumnListRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from ColumnsClauseRole
(via NamedColumn
, ColumnElement
):
Class Variable | _role_name |
Undocumented |
Inherited from AllowsLambdaRole
(via NamedColumn
, ColumnElement
, ColumnsClauseRole
):
Class Variable | allows_lambda |
Undocumented |
Inherited from UsesInspection
(via NamedColumn
, ColumnElement
, ColumnsClauseRole
):
Class Variable | _post_inspect |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, ColumnsClauseRole
, ColumnListRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from LimitOffsetRole
(via NamedColumn
, ColumnElement
):
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, LimitOffsetRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from DMLColumnRole
(via NamedColumn
, ColumnElement
):
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, DMLColumnRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from DDLConstraintColumnRole
(via NamedColumn
, ColumnElement
):
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, DDLConstraintColumnRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from DDLExpressionRole
(via NamedColumn
, ColumnElement
):
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, DDLExpressionRole
, StructuralRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from ColumnOperators
(via NamedColumn
, ColumnElement
):
Method | __add__ |
Implement the + operator. |
Method | __contains__ |
Undocumented |
Method | __div__ |
Implement the / operator. |
Method | __eq__ |
Implement the == operator. |
Method | __ge__ |
Implement the >= operator. |
Method | __getitem__ |
Implement the [] operator. |
Method | __gt__ |
Implement the > operator. |
Method | __le__ |
Implement the <= operator. |
Method | __lshift__ |
implement the << operator. |
Method | __lt__ |
Implement the < operator. |
Method | __mod__ |
Implement the % operator. |
Method | __mul__ |
Implement the * operator. |
Method | __ne__ |
Implement the != operator. |
Method | __neg__ |
Implement the - operator. |
Method | __radd__ |
Implement the + operator in reverse. |
Method | __rdiv__ |
Implement the / operator in reverse. |
Method | __rmod__ |
Implement the % operator in reverse. |
Method | __rmul__ |
Implement the * operator in reverse. |
Method | __rshift__ |
implement the >> operator. |
Method | __rsub__ |
Implement the - operator in reverse. |
Method | __rtruediv__ |
Implement the // operator in reverse. |
Method | __sub__ |
Implement the - operator. |
Method | __truediv__ |
Implement the // operator. |
Method | all_ |
Produce an _expression.all_ clause against the parent object. |
Method | any_ |
Produce an _expression.any_ clause against the parent object. |
Method | asc |
Produce a _expression.asc clause against the parent object. |
Method | between |
Produce a _expression.between clause against the parent object, given the lower and upper range. |
Method | collate |
Produce a _expression.collate clause against the parent object, given the collation string. |
Method | concat |
Implement the 'concat' operator. |
Method | contains |
Implement the 'contains' operator. |
Method | desc |
Produce a _expression.desc clause against the parent object. |
Method | distinct |
Produce a _expression.distinct clause against the parent object. |
Method | endswith |
Implement the 'endswith' operator. |
Method | ilike |
Implement the ilike operator, e.g. case insensitive LIKE. |
Method | in_ |
Implement the in operator. |
Method | is_ |
Implement the IS operator. |
Method | is_distinct_from |
Implement the IS DISTINCT FROM operator. |
Method | is_not |
Implement the IS NOT operator. |
Method | is_not_distinct_from |
Implement the IS NOT DISTINCT FROM operator. |
Method | like |
Implement the like operator. |
Method | match |
Implements a database-specific 'match' operator. |
Method | not_ilike |
implement the NOT ILIKE operator. |
Method | not_in |
implement the NOT IN operator. |
Method | not_like |
implement the NOT LIKE operator. |
Method | nulls_first |
Produce a _expression.nulls_first clause against the parent object. |
Method | nulls_last |
Produce a _expression.nulls_last clause against the parent object. |
Method | regexp_match |
Implements a database-specific 'regexp match' operator. |
Method | regexp_replace |
Implements a database-specific 'regexp replace' operator. |
Method | startswith |
Implement the startswith operator. |
Class Variable | __slots__ |
Undocumented |
Class Variable | timetuple |
Hack, allows datetime objects to be compared on the LHS. |
Inherited from Operators
(via NamedColumn
, ColumnElement
, ColumnOperators
):
Method | __and__ |
Implement the & operator. |
Method | __invert__ |
Implement the ~ operator. |
Method | __or__ |
Implement the | operator. |
Method | bool_op |
Return a custom boolean operator. |
Method | op |
Produce a generic operator function. |
Inherited from ClauseElement
(via NamedColumn
, ColumnElement
):
Method | compare |
Compare this _expression.ClauseElement to the given _expression.ClauseElement . |
Method | compile |
Compile this SQL expression. |
Method | params |
Return a copy with _expression.bindparam elements replaced. |
Method | unique_params |
Return a copy with _expression.bindparam elements replaced. |
Method | __bool__ |
Undocumented |
Method | __getstate__ |
Undocumented |
Method | __invert__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __str__ |
Undocumented |
Method | _cloned_set |
Return the set consisting all cloned ancestors of this ClauseElement. |
Method | _compile_w_cache |
Undocumented |
Method | _compiler |
Return a compiler appropriate for this ClauseElement, given a Dialect. |
Method | _execute_on_connection |
Undocumented |
Method | _negate_in_binary |
a hook to allow the right side of a binary expression to respond to a negation of the binary expression. |
Method | _replace_params |
Undocumented |
Method | _set_propagate_attrs |
Undocumented |
Method | _ungroup |
Return this _expression.ClauseElement without any groupings. |
Method | _with_binary_element_type |
in the context of binary expression, convert the type of this object to the one given. |
Class Variable | _cache_key_traversal |
Undocumented |
Class Variable | _is_bind_parameter |
Undocumented |
Class Variable | _is_clause_list |
Undocumented |
Class Variable | _is_clone_of |
Undocumented |
Class Variable | _is_from_clause |
Undocumented |
Class Variable | _is_from_container |
Undocumented |
Class Variable | _is_immutable |
Undocumented |
Class Variable | _is_lambda_element |
Undocumented |
Class Variable | _is_returns_rows |
Undocumented |
Class Variable | _is_select_container |
Undocumented |
Class Variable | _is_select_statement |
Undocumented |
Class Variable | _is_singleton_constant |
Undocumented |
Class Variable | _is_text_clause |
Undocumented |
Class Variable | _is_textual |
Undocumented |
Class Variable | _order_by_label_element |
Undocumented |
Class Variable | bind |
Undocumented |
Class Variable | is_clause_element |
Undocumented |
Class Variable | is_selectable |
Undocumented |
Class Variable | stringify_dialect |
Undocumented |
Class Variable | supports_execution |
Undocumented |
Instance Variable | _propagate_attrs |
like annotations, however these propagate outwards liberally as SQL constructs are built, and are set up at construction time. |
Property | _constructor |
return the 'constructor' for this ClauseElement. |
Inherited from SQLRole
(via NamedColumn
, ColumnElement
, ClauseElement
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from SupportsWrappingAnnotations
(via NamedColumn
, ColumnElement
, ClauseElement
):
Method | _annotate |
return a copy of this ClauseElement with annotations updated by the given dictionary. |
Method | _deannotate |
return a copy of this _expression.ClauseElement with annotations removed. |
Method | _with_annotations |
return a copy of this ClauseElement with annotations replaced by the given dictionary. |
Inherited from SupportsAnnotations
(via NamedColumn
, ColumnElement
, ClauseElement
, SupportsWrappingAnnotations
):
Property | _annotations_cache_key |
Undocumented |
Inherited from MemoizedHasCacheKey
(via NamedColumn
, ColumnElement
, ClauseElement
):
Method | _generate_cache_key |
return a cache key. |
Inherited from HasCacheKey
(via NamedColumn
, ColumnElement
, ClauseElement
, MemoizedHasCacheKey
):
Class Variable | inherit_cache |
Indicate if this .HasCacheKey instance should make use of the cache key generation scheme used by its immediate superclass. |
Class Method | _generate_cache_attrs |
generate cache key dispatcher for a new class. |
Class Method | _generate_cache_key_for_object |
Undocumented |
Method | _gen_cache_key |
return an optional cache key. |
Class Variable | __slots__ |
Undocumented |
Class Variable | _hierarchy_supports_caching |
private attribute which may be set to False to prevent the inherit_cache warning from being emitted for a hierarchy of subclasses. |
Class Variable | _is_has_cache_key |
Undocumented |
Inherited from HasCopyInternals
(via NamedColumn
, ColumnElement
, ClauseElement
):
Method | _copy_internals |
Reassign internal elements to be clones of themselves. |
Inherited from Traversible
(via NamedColumn
, ColumnElement
, ClauseElement
):
Method | __class_getitem__ |
Undocumented |
sqlalchemy.sql.schema.Column
Produce a .ColumnClause
object.
The .ColumnClause
is a lightweight analogue to the
_schema.Column
class. The _expression.column
function can
be invoked with just a name alone, as in:
from sqlalchemy import column id, name = column("id"), column("name") stmt = select(id, name).select_from("user")
The above statement would produce SQL like:
SELECT id, name FROM user
Once constructed, _expression.column
may be used like any other SQL
expression element such as within _expression.select
constructs:
from sqlalchemy.sql import column id, name = column("id"), column("name") stmt = select(id, name).select_from("user")
The text handled by _expression.column
is assumed to be handled
like the name of a database column; if the string contains mixed case,
special characters, or matches a known reserved word on the target
backend, the column expression will render using the quoting
behavior determined by the backend. To produce a textual SQL
expression that is rendered exactly without any quoting,
use _expression.literal_column
instead,
or pass True as the
value of :paramref:`_expression.column.is_literal`. Additionally,
full SQL
statements are best handled using the _expression.text
construct.
_expression.column
can be used in a table-like
fashion by combining it with the .table
function
(which is the lightweight analogue to _schema.Table
) to produce
a working table construct with minimal boilerplate:
from sqlalchemy import table, column, select user = table("user", column("id"), column("name"), column("description"), ) stmt = select(user.c.description).where(user.c.name == 'wendy')
A _expression.column
/ .table
construct like that illustrated
above can be created in an
ad-hoc fashion and is not associated with any
_schema.MetaData
, DDL, or events, unlike its
_schema.Table
counterpart.
_expression.column
can now
be imported from the plain sqlalchemy namespace like any
other SQL element.See Also
_schema.Column
_expression.literal_column
.table
_expression.text
Parameters | |
text | the text of the element. |
type_ | Undocumented |
is_literal | if True, the .ColumnClause is assumed to
be an exact expression that will be delivered to the output with no
quoting rules applied regardless of case sensitive settings. the
_expression.literal_column() function essentially invokes
_expression.column while passing is_literal=True. |
_selectable | Undocumented |
type | _types.TypeEngine object which can associate
this .ColumnClause with a type. |
sqlalchemy.sql.base.Immutable._clone
Create a shallow copy of this ClauseElement.
This method may be used by a generative API. Its also used as part of the "deep" copy afforded by a traversal that combines the _copy_internals() method.
generate table-qualified label
for a table-bound column this is <tablename>_<columnname>.
used primarily for LABEL_STYLE_TABLENAME_PLUS_COL as well as the .columns collection on a Join object.
sqlalchemy.sql.schema.Column
_expression.ColumnElement
representing this
_expression.ColumnElement
as it appears in the select list of
a descending selectable.Return immediate child .visitors.Traversible
elements of this .visitors.Traversible
.
This is used for visit traversal.
**kw 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).
sqlalchemy.sql.schema.Column
The 'key' that in some circumstances refers to this object in a Python namespace.
This typically refers to the "key" of the column as present in the
.c collection of a selectable, e.g. sometable.c["somekey"] would
return a _schema.Column
with a .key of "somekey".