class Column(DialectKWArgs, SchemaItem, ColumnClause[
Represents a column in a database table.
Method | __init__ |
Construct a new ``Column`` object. |
Method | __repr__ |
Undocumented |
Method | __str__ |
Undocumented |
Method | append |
Undocumented |
Method | copy |
Undocumented |
Method | references |
Return True if this Column references the given column via foreign key. |
Class Variable | __visit |
Undocumented |
Class Variable | inherit |
Indicate if this :class:`.HasCacheKey` instance should make use of the cache key generation scheme used by its immediate superclass. |
Instance Variable | autoincrement |
Undocumented |
Instance Variable | comment |
Undocumented |
Instance Variable | computed |
Undocumented |
Instance Variable | constraints |
Undocumented |
Instance Variable | default |
Undocumented |
Instance Variable | doc |
Undocumented |
Instance Variable | foreign |
A collection of all :class:`_schema.ForeignKey` marker objects associated with this :class:`_schema.Column`. |
Instance Variable | identity |
Undocumented |
Instance Variable | index |
The value of the :paramref:`_schema.Column.index` parameter. |
Instance Variable | info |
Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.SchemaItem`. |
Instance Variable | key |
The 'key' that in some circumstances refers to this object in a Python namespace. |
Instance Variable | nullable |
Undocumented |
Instance Variable | onupdate |
Undocumented |
Instance Variable | primary |
Undocumented |
Instance Variable | server |
Undocumented |
Instance Variable | server |
Undocumented |
Instance Variable | system |
Undocumented |
Instance Variable | table |
Undocumented |
Instance Variable | type |
Undocumented |
Instance Variable | unique |
The value of the :paramref:`_schema.Column.unique` parameter. |
Method | _copy |
Create a copy of this ``Column``, uninitialized. |
Method | _extra |
Undocumented |
Method | _make |
Create a *proxy* for this column. |
Method | _merge |
merge the elements of another column into this one. |
Method | _on |
Undocumented |
Method | _set |
Associate with this SchemaEvent's parent object. |
Method | _set |
Undocumented |
Method | _setup |
Undocumented |
Instance Variable | _proxies |
Undocumented |
Instance Variable | _user |
Undocumented |
Property | _gen |
special attribute used by cache key gen, if true, we will use a static cache key for the annotations dictionary, else we will generate a new cache key for annotations each time. |
Inherited from DialectKWArgs
:
Class Method | argument |
Add a new kind of dialect-specific keyword argument for this class. |
Class Variable | __slots__ |
Undocumented |
Property | dialect |
A collection of keyword arguments specified as dialect-specific options to this construct. |
Property | dialect |
A collection of keyword arguments specified as dialect-specific options to this construct. |
Property | kwargs |
A synonym for :attr:`.DialectKWArgs.dialect_kwargs`. |
Method | _kw |
Undocumented |
Method | _validate |
Undocumented |
Class Variable | _dialect |
Undocumented |
Class Variable | _kw |
Undocumented |
Inherited from SchemaItem
(via DialectKWArgs
):
Class Variable | create |
Undocumented |
Method | _init |
Initialize the list of child items for this SchemaItem. |
Method | _schema |
Undocumented |
Class Variable | _use |
Undocumented |
Inherited from SchemaEventTarget
(via DialectKWArgs
, SchemaItem
):
Class Variable | dispatch |
Undocumented |
Method | _set |
Undocumented |
Inherited from ColumnClause
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
):
Method | get |
Return immediate child :class:`.visitors.HasTraverseInternals` elements of this :class:`.visitors.HasTraverseInternals`. |
Instance Variable | is |
Undocumented |
Instance Variable | name |
Undocumented |
Property | entity |
Undocumented |
Method | _clone |
Create a shallow copy of this ClauseElement. |
Method | _compare |
Return True if the given column element compares to this one when targeting within a result row. |
Method | _from |
Undocumented |
Method | _gen |
generate table-qualified label |
Method | _render |
A flag used by select._columns_plus_names that helps to determine we are actually going to render in terms of "SELECT <col> AS <label>". This flag can be returned as False for some Column objects that want to be rendered as simple "SELECT <col>"; typically columns that don't have any parent table and are named the same as what the label would be in any case. |
Class Variable | _is |
Undocumented |
Class Variable | _traverse |
Undocumented |
Property | _ddl |
Undocumented |
Property | _is |
Undocumented |
Inherited from DDLReferredColumnRole
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
):
Class Variable | _role |
Undocumented |
Inherited from Immutable
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
):
Method | params |
Undocumented |
Method | unique |
Undocumented |
Method | _copy |
Undocumented |
Class Variable | _is |
Undocumented |
Inherited from NamedColumn
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
):
Property | description |
Undocumented |
Method | _bind |
Undocumented |
Method | _non |
the 'name' that naturally applies this element when rendered in SQL. |
Method | _tq |
table qualified label based on column key. |
Method | _tq |
table qualified label based on column name. |
Inherited from KeyedColumnElement
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
):
Class Variable | _is |
Undocumented |
Inherited from ColumnElement
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
):
Method | __getattr__ |
Undocumented |
Method | cast |
Produce a type cast, i.e. ``CAST(<expression> AS <type>)``. |
Method | comparator |
Undocumented |
Method | label |
Produce a column label, i.e. ``<columnname> AS <name>``. |
Method | operate |
Operate on an argument. |
Method | reverse |
Reverse operate on an argument. |
Method | self |
Apply a 'grouping' to this :class:`_expression.ClauseElement`. |
Method | shares |
Return True if the given :class:`_expression.ColumnElement` has a common ancestor to this :class:`_expression.ColumnElement`. |
Property | anon |
Undocumented |
Property | anon |
Undocumented |
Property | base |
Undocumented |
Property | expression |
Return a column expression. |
Property | proxy |
set of all columns we are proxying |
Method | _anon |
Undocumented |
Method | _dedupe |
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 |
Undocumented |
Method | _expression |
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 |
Undocumented |
Method | _uncached |
An 'uncached' version of proxy set. |
Class Variable | _allow |
A flag that can be flipped to prevent a column from being resolvable by string label name. |
Class Variable | _alt |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Property | _anon |
Provides a constant 'anonymous key label' for this ColumnElement. |
Property | _anon |
Provides a constant 'anonymous label' for this ColumnElement. |
Property | _anon |
Undocumented |
Property | _anon |
Undocumented |
Property | _expanded |
Undocumented |
Property | _key |
legacy; renamed to _tq_key_label |
Property | _label |
legacy; renamed to _tq_label |
Property | _select |
Undocumented |
Inherited from AllowsLambdaRole
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
):
Class Variable | allows |
Undocumented |
Inherited from UsesInspection
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
):
Class Variable | uses |
Undocumented |
Class Variable | _post |
Undocumented |
Inherited from SQLCoreOperations
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
):
Method | __add__ |
Implement the ``+`` operator. |
Method | __and__ |
Implement the ``&`` operator. |
Method | __contains__ |
Undocumented |
Method | __eq__ |
Implement the ``==`` operator. |
Method | __floordiv__ |
Implement the ``//`` operator. |
Method | __ge__ |
Implement the ``>=`` operator. |
Method | __getitem__ |
Implement the [] operator. |
Method | __gt__ |
Implement the ``>`` operator. |
Method | __invert__ |
Implement the ``~`` operator. |
Method | __le__ |
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 | __or__ |
Implement the ``|`` operator. |
Method | __radd__ |
Implement the ``+`` operator in reverse. |
Method | __rfloordiv__ |
Implement the ``//`` operator in reverse. |
Method | __rmod__ |
Implement the ``%`` operator in reverse. |
Method | __rmul__ |
Implement the ``*`` operator in reverse. |
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 :func:`_expression.all_` clause against the parent object. |
Method | any_ |
Produce an :func:`_expression.any_` clause against the parent object. |
Method | asc |
Produce a :func:`_expression.asc` clause against the parent object. |
Method | between |
Produce a :func:`_expression.between` clause against the parent object, given the lower and upper range. |
Method | bool |
Return a custom boolean operator. |
Method | collate |
Produce a :func:`_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 :func:`_expression.desc` clause against the parent object. |
Method | distinct |
Produce a :func:`_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 |
Implement the ``IS DISTINCT FROM`` operator. |
Method | is |
Implement the ``IS NOT`` operator. |
Method | is |
Implement the ``IS NOT DISTINCT FROM`` operator. |
Method | isnot |
Undocumented |
Method | like |
Implement the ``like`` operator. |
Method | match |
Implements a database-specific 'match' operator. |
Method | not |
implement the ``NOT ILIKE`` operator. |
Method | not |
implement the ``NOT IN`` operator. |
Method | not |
implement the ``NOT LIKE`` operator. |
Method | notilike |
Undocumented |
Method | notin_ |
Undocumented |
Method | notlike |
Undocumented |
Method | nulls |
Produce a :func:`_expression.nulls_first` clause against the parent object. |
Method | nulls |
Produce a :func:`_expression.nulls_last` clause against the parent object. |
Method | nullsfirst |
Undocumented |
Method | nullslast |
Undocumented |
Method | op |
Produce a generic operator function. |
Method | regexp |
Implements a database-specific 'regexp match' operator. |
Method | regexp |
Implements a database-specific 'regexp replace' operator. |
Method | startswith |
Implement the ``startswith`` operator. |
Property | _propagate |
Undocumented |
Inherited from ColumnOperators
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
):
Method | __lshift__ |
implement the << operator. |
Method | __rshift__ |
implement the >> operator. |
Method | bitwise |
Produce a bitwise AND operation, typically via the ``&`` operator. |
Method | bitwise |
Produce a bitwise LSHIFT operation, typically via the ``<<`` operator. |
Method | bitwise |
Produce a bitwise NOT operation, typically via the ``~`` operator. |
Method | bitwise |
Produce a bitwise OR operation, typically via the ``|`` operator. |
Method | bitwise |
Produce a bitwise RSHIFT operation, typically via the ``>>`` operator. |
Method | bitwise |
Produce a bitwise XOR operation, typically via the ``^`` operator, or ``#`` for PostgreSQL. |
Method | icontains |
Implement the ``icontains`` operator, e.g. case insensitive version of :meth:`.ColumnOperators.contains`. |
Method | iendswith |
Implement the ``iendswith`` operator, e.g. case insensitive version of :meth:`.ColumnOperators.endswith`. |
Method | isnot |
Undocumented |
Method | istartswith |
Implement the ``istartswith`` operator, e.g. case insensitive version of :meth:`.ColumnOperators.startswith`. |
Class Variable | timetuple |
Hack, allows datetime objects to be compared on the LHS. |
Method | _rconcat |
Implement an 'rconcat' operator. |
Inherited from DQLDMLClauseElement
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, SQLRole
):
Method | compile |
Compile this SQL expression. |
Method | _compiler |
Return a compiler appropriate for this ClauseElement, given a Dialect. |
Inherited from ClauseElement
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, SQLRole
, DQLDMLClauseElement
):
Method | __bool__ |
Undocumented |
Method | __getstate__ |
Undocumented |
Method | compare |
Compare this :class:`_expression.ClauseElement` to the given :class:`_expression.ClauseElement`. |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | negation |
Undocumented |
Method | _cloned |
Return the set consisting all cloned ancestors of this ClauseElement. |
Method | _compile |
Undocumented |
Method | _execute |
Undocumented |
Method | _execute |
an additional hook for subclasses to provide a different implementation for connection.scalar() vs. connection.execute(). |
Method | _negate |
a hook to allow the right side of a binary expression to respond to a negation of the binary expression. |
Method | _replace |
Undocumented |
Method | _set |
Undocumented |
Method | _ungroup |
Return this :class:`_expression.ClauseElement` without any groupings. |
Method | _with |
in the context of binary expression, convert the type of this object to the one given. |
Class Variable | _cache |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Property | _constructor |
return the 'constructor' for this ClauseElement. |
Property | _order |
Undocumented |
Inherited from SupportsWrappingAnnotations
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, SQLRole
, DQLDMLClauseElement
, ClauseElement
):
Method | _annotate |
return a copy of this ClauseElement with annotations updated by the given dictionary. |
Method | _deannotate |
return a copy of this :class:`_expression.ClauseElement` with annotations removed. |
Method | _with |
return a copy of this ClauseElement with annotations replaced by the given dictionary. |
Inherited from SupportsAnnotations
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
):
Method | _gen |
Undocumented |
Property | _annotations |
Undocumented |
Inherited from MemoizedHasCacheKey
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
):
Method | _generate |
return a cache key. |
Inherited from HasCacheKey
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
):
Class Method | _generate |
generate cache key dispatcher for a new class. |
Class Method | _generate |
Undocumented |
Method | _gen |
return an optional cache key. |
Class Variable | _generated |
Undocumented |
Class Variable | _hierarchy |
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 |
Undocumented |
Inherited from CompilerElement
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
, HasCacheKey
, HasCopyInternals
, ExternallyTraversible
, HasTraverseInternals
):
Class Variable | stringify |
Undocumented |
Class Variable | supports |
Undocumented |
Inherited from Visitable
(via DialectKWArgs
, SchemaItem
, SchemaEventTarget
, EventTarget
, ColumnClause
, DDLReferredColumnRole
, LabeledColumnExprRole
, StrAsPlainColumnRole
, Immutable
, NamedColumn
, KeyedColumnElement
, ColumnElement
, ColumnArgumentOrKeyRole
, ColumnArgumentRole
, StatementOptionRole
, WhereHavingRole
, OnClauseRole
, BinaryElementRole
, OrderByRole
, ColumnsClauseRole
, AllowsLambdaRole
, ByOfRole
, UsesInspection
, ColumnListRole
, LimitOffsetRole
, DMLColumnRole
, DDLConstraintColumnRole
, DDLExpressionRole
, StructuralRole
, SQLColumnExpression
, SQLCoreOperations
, ExpressionElementRole
, TypedColumnsClauseRole
, ColumnOperators
, Operators
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
, HasCacheKey
, HasCopyInternals
, ExternallyTraversible
, HasTraverseInternals
, CompilerElement
):
Method | __class |
Undocumented |
Method | __init |
Undocumented |
Class Method | _generate |
Undocumented |
Method | _compiler |
Undocumented |
Class Variable | _original |
Undocumented |
Optional[ Union[ str, _TypeEngineArgument[ _T], SchemaEventTarget]]
= None, __type_pos: Optional[ Union[ _TypeEngineArgument[ _T], SchemaEventTarget]]
= None, *args: SchemaEventTarget
, name: Optional[ str]
= None, type_: Optional[ _TypeEngineArgument[ _T]]
= None, autoincrement: _AutoIncrementType
= 'auto', default: Optional[ Any]
= None, doc: Optional[ str]
= None, key: Optional[ str]
= None, index: Optional[ bool]
= None, unique: Optional[ bool]
= None, info: Optional[ _InfoType]
= None, nullable: Optional[ Union[ bool, Literal[ SchemaConst.NULL_UNSPECIFIED]]]
= SchemaConst.NULL_UNSPECIFIED, onupdate: Optional[ Any]
= None, primary_key: bool
= False, server_default: Optional[ _ServerDefaultType]
= None, server_onupdate: Optional[ FetchedValue]
= None, quote: Optional[ bool]
= None, system: bool
= False, comment: Optional[ str]
= None, _proxies: Optional[ Any]
= None, **dialect_kwargs: Any
):
(source)
¶
Construct a new ``Column`` object. :param name: The name of this column as represented in the database. This argument may be the first positional argument, or specified via keyword. Names which contain no upper case characters will be treated as case insensitive names, and will not be quoted unless they are a reserved word. Names with any number of upper case characters will be quoted and sent exactly. Note that this behavior applies even for databases which standardize upper case names as case insensitive such as Oracle. The name field may be omitted at construction time and applied later, at any time before the Column is associated with a :class:`_schema.Table`. This is to support convenient usage within the :mod:`~sqlalchemy.ext.declarative` extension. :param type\_: The column's type, indicated using an instance which subclasses :class:`~sqlalchemy.types.TypeEngine`. If no arguments are required for the type, the class of the type can be sent as well, e.g.:: # use a type with arguments Column('data', String(50)) # use no arguments Column('level', Integer) The ``type`` argument may be the second positional argument or specified by keyword. If the ``type`` is ``None`` or is omitted, it will first default to the special type :class:`.NullType`. If and when this :class:`_schema.Column` is made to refer to another column using :class:`_schema.ForeignKey` and/or :class:`_schema.ForeignKeyConstraint`, the type of the remote-referenced column will be copied to this column as well, at the moment that the foreign key is resolved against that remote :class:`_schema.Column` object. .. versionchanged:: 0.9.0 Support for propagation of type to a :class:`_schema.Column` from its :class:`_schema.ForeignKey` object has been improved and should be more reliable and timely. :param \*args: Additional positional arguments include various :class:`.SchemaItem` derived constructs which will be applied as options to the column. These include instances of :class:`.Constraint`, :class:`_schema.ForeignKey`, :class:`.ColumnDefault`, :class:`.Sequence`, :class:`.Computed` :class:`.Identity`. In some cases an equivalent keyword argument is available such as ``server_default``, ``default`` and ``unique``. :param autoincrement: Set up "auto increment" semantics for an **integer primary key column with no foreign key dependencies** (see later in this docstring for a more specific definition). This may influence the :term:`DDL` that will be emitted for this column during a table create, as well as how the column will be considered when INSERT statements are compiled and executed. The default value is the string ``"auto"``, which indicates that a single-column (i.e. non-composite) primary key that is of an INTEGER type with no other client-side or server-side default constructs indicated should receive auto increment semantics automatically. Other values include ``True`` (force this column to have auto-increment semantics for a :term:`composite primary key` as well), ``False`` (this column should never have auto-increment semantics), and the string ``"ignore_fk"`` (special-case for foreign key columns, see below). The term "auto increment semantics" refers both to the kind of DDL that will be emitted for the column within a CREATE TABLE statement, when methods such as :meth:`.MetaData.create_all` and :meth:`.Table.create` are invoked, as well as how the column will be considered when an INSERT statement is compiled and emitted to the database: * **DDL rendering** (i.e. :meth:`.MetaData.create_all`, :meth:`.Table.create`): When used on a :class:`.Column` that has no other default-generating construct associated with it (such as a :class:`.Sequence` or :class:`.Identity` construct), the parameter will imply that database-specific keywords such as PostgreSQL ``SERIAL``, MySQL ``AUTO_INCREMENT``, or ``IDENTITY`` on SQL Server should also be rendered. Not every database backend has an "implied" default generator available; for example the Oracle backend always needs an explicit construct such as :class:`.Identity` to be included with a :class:`.Column` in order for the DDL rendered to include auto-generating constructs to also be produced in the database. * **INSERT semantics** (i.e. when a :func:`_sql.insert` construct is compiled into a SQL string and is then executed on a database using :meth:`_engine.Connection.execute` or equivalent): A single-row INSERT statement will be known to produce a new integer primary key value automatically for this column, which will be accessible after the statement is invoked via the :attr:`.CursorResult.inserted_primary_key` attribute upon the :class:`_result.Result` object. This also applies towards use of the ORM when ORM-mapped objects are persisted to the database, indicating that a new integer primary key will be available to become part of the :term:`identity key` for that object. This behavior takes place regardless of what DDL constructs are associated with the :class:`_schema.Column` and is independent of the "DDL Rendering" behavior discussed in the previous note above. The parameter may be set to ``True`` to indicate that a column which is part of a composite (i.e. multi-column) primary key should have autoincrement semantics, though note that only one column within a primary key may have this setting. It can also be set to ``True`` to indicate autoincrement semantics on a column that has a client-side or server-side default configured, however note that not all dialects can accommodate all styles of default as an "autoincrement". It can also be set to ``False`` on a single-column primary key that has a datatype of INTEGER in order to disable auto increment semantics for that column. .. versionchanged:: 1.1 The autoincrement flag now defaults to ``"auto"`` which indicates autoincrement semantics by default for single-column integer primary keys only; for composite (multi-column) primary keys, autoincrement is never implicitly enabled; as always, ``autoincrement=True`` will allow for at most one of those columns to be an "autoincrement" column. ``autoincrement=True`` may also be set on a :class:`_schema.Column` that has an explicit client-side or server-side default, subject to limitations of the backend database and dialect. The setting *only* has an effect for columns which are: * Integer derived (i.e. INT, SMALLINT, BIGINT). * Part of the primary key * Not referring to another column via :class:`_schema.ForeignKey`, unless the value is specified as ``'ignore_fk'``:: # turn on autoincrement for this column despite # the ForeignKey() Column('id', ForeignKey('other.id'), primary_key=True, autoincrement='ignore_fk') It is typically not desirable to have "autoincrement" enabled on a column that refers to another via foreign key, as such a column is required to refer to a value that originates from elsewhere. The setting has these effects on columns that meet the above criteria: * DDL issued for the column, if the column does not already include a default generating construct supported by the backend such as :class:`.Identity`, will include database-specific keywords intended to signify this column as an "autoincrement" column for specific backends. Behavior for primary SQLAlchemy dialects includes: * AUTO INCREMENT on MySQL and MariaDB * SERIAL on PostgreSQL * IDENTITY on MS-SQL - this occurs even without the :class:`.Identity` construct as the :paramref:`.Column.autoincrement` parameter pre-dates this construct. * SQLite - SQLite integer primary key columns are implicitly "auto incrementing" and no additional keywords are rendered; to render the special SQLite keyword ``AUTOINCREMENT`` is not included as this is unnecessary and not recommended by the database vendor. See the section :ref:`sqlite_autoincrement` for more background. * Oracle - The Oracle dialect has no default "autoincrement" feature available at this time, instead the :class:`.Identity` construct is recommended to achieve this (the :class:`.Sequence` construct may also be used). * Third-party dialects - consult those dialects' documentation for details on their specific behaviors. * When a single-row :func:`_sql.insert` construct is compiled and executed, which does not set the :meth:`_sql.Insert.inline` modifier, newly generated primary key values for this column will be automatically retrieved upon statement execution using a method specific to the database driver in use: * MySQL, SQLite - calling upon ``cursor.lastrowid()`` (see `https://www.python.org/dev/peps/pep-0249/#lastrowid <https://www.python.org/dev/peps/pep-0249/#lastrowid>`_) * PostgreSQL, SQL Server, Oracle - use RETURNING or an equivalent construct when rendering an INSERT statement, and then retrieving the newly generated primary key values after execution * PostgreSQL, Oracle for :class:`_schema.Table` objects that set :paramref:`_schema.Table.implicit_returning` to False - for a :class:`.Sequence` only, the :class:`.Sequence` is invoked explicitly before the INSERT statement takes place so that the newly generated primary key value is available to the client * SQL Server for :class:`_schema.Table` objects that set :paramref:`_schema.Table.implicit_returning` to False - the ``SELECT scope_identity()`` construct is used after the INSERT statement is invoked to retrieve the newly generated primary key value. * Third-party dialects - consult those dialects' documentation for details on their specific behaviors. * For multiple-row :func:`_sql.insert` constructs invoked with a list of parameters (i.e. "executemany" semantics), primary-key retrieving behaviors are generally disabled, however there may be special APIs that may be used to retrieve lists of new primary key values for an "executemany", such as the psycopg2 "fast insertmany" feature. Such features are very new and may not yet be well covered in documentation. :param default: A scalar, Python callable, or :class:`_expression.ColumnElement` expression representing the *default value* for this column, which will be invoked upon insert if this column is otherwise not specified in the VALUES clause of the insert. This is a shortcut to using :class:`.ColumnDefault` as a positional argument; see that class for full detail on the structure of the argument. Contrast this argument to :paramref:`_schema.Column.server_default` which creates a default generator on the database side. .. seealso:: :ref:`metadata_defaults_toplevel` :param doc: optional String that can be used by the ORM or similar to document attributes on the Python side. This attribute does **not** render SQL comments; use the :paramref:`_schema.Column.comment` parameter for this purpose. :param key: An optional string identifier which will identify this ``Column`` object on the :class:`_schema.Table`. When a key is provided, this is the only identifier referencing the ``Column`` within the application, including ORM attribute mapping; the ``name`` field is used only when rendering SQL. :param index: When ``True``, indicates that a :class:`_schema.Index` construct will be automatically generated for this :class:`_schema.Column`, which will result in a "CREATE INDEX" statement being emitted for the :class:`_schema.Table` when the DDL create operation is invoked. Using this flag is equivalent to making use of the :class:`_schema.Index` construct explicitly at the level of the :class:`_schema.Table` construct itself:: Table( "some_table", metadata, Column("x", Integer), Index("ix_some_table_x", "x") ) To add the :paramref:`_schema.Index.unique` flag to the :class:`_schema.Index`, set both the :paramref:`_schema.Column.unique` and :paramref:`_schema.Column.index` flags to True simultaneously, which will have the effect of rendering the "CREATE UNIQUE INDEX" DDL instruction instead of "CREATE INDEX". The name of the index is generated using the :ref:`default naming convention <constraint_default_naming_convention>` which for the :class:`_schema.Index` construct is of the form ``ix_<tablename>_<columnname>``. As this flag is intended only as a convenience for the common case of adding a single-column, default configured index to a table definition, explicit use of the :class:`_schema.Index` construct should be preferred for most use cases, including composite indexes that encompass more than one column, indexes with SQL expressions or ordering, backend-specific index configuration options, and indexes that use a specific name. .. note:: the :attr:`_schema.Column.index` attribute on :class:`_schema.Column` **does not indicate** if this column is indexed or not, only if this flag was explicitly set here. To view indexes on a column, view the :attr:`_schema.Table.indexes` collection or use :meth:`_reflection.Inspector.get_indexes`. .. seealso:: :ref:`schema_indexes` :ref:`constraint_naming_conventions` :paramref:`_schema.Column.unique` :param info: Optional data dictionary which will be populated into the :attr:`.SchemaItem.info` attribute of this object. :param nullable: When set to ``False``, will cause the "NOT NULL" phrase to be added when generating DDL for the column. When ``True``, will normally generate nothing (in SQL this defaults to "NULL"), except in some very specific backend-specific edge cases where "NULL" may render explicitly. Defaults to ``True`` unless :paramref:`_schema.Column.primary_key` is also ``True`` or the column specifies a :class:`_sql.Identity`, in which case it defaults to ``False``. This parameter is only used when issuing CREATE TABLE statements. .. note:: When the column specifies a :class:`_sql.Identity` this parameter is in general ignored by the DDL compiler. The PostgreSQL database allows nullable identity column by setting this parameter to ``True`` explicitly. :param onupdate: A scalar, Python callable, or :class:`~sqlalchemy.sql.expression.ClauseElement` representing a default value to be applied to the column within UPDATE statements, which will be invoked upon update if this column is not present in the SET clause of the update. This is a shortcut to using :class:`.ColumnDefault` as a positional argument with ``for_update=True``. .. seealso:: :ref:`metadata_defaults` - complete discussion of onupdate :param primary_key: If ``True``, marks this column as a primary key column. Multiple columns can have this flag set to specify composite primary keys. As an alternative, the primary key of a :class:`_schema.Table` can be specified via an explicit :class:`.PrimaryKeyConstraint` object. :param server_default: A :class:`.FetchedValue` instance, str, Unicode or :func:`~sqlalchemy.sql.expression.text` construct representing the DDL DEFAULT value for the column. String types will be emitted as-is, surrounded by single quotes:: Column('x', Text, server_default="val") x TEXT DEFAULT 'val' A :func:`~sqlalchemy.sql.expression.text` expression will be rendered as-is, without quotes:: Column('y', DateTime, server_default=text('NOW()')) y DATETIME DEFAULT NOW() Strings and text() will be converted into a :class:`.DefaultClause` object upon initialization. This parameter can also accept complex combinations of contextually valid SQLAlchemy expressions or constructs:: from sqlalchemy import create_engine from sqlalchemy import Table, Column, MetaData, ARRAY, Text from sqlalchemy.dialects.postgresql import array engine = create_engine( 'postgresql+psycopg2://scott:tiger@localhost/mydatabase' ) metadata_obj = MetaData() tbl = Table( "foo", metadata_obj, Column("bar", ARRAY(Text), server_default=array(["biz", "bang", "bash"]) ) ) metadata_obj.create_all(engine) The above results in a table created with the following SQL:: CREATE TABLE foo ( bar TEXT[] DEFAULT ARRAY['biz', 'bang', 'bash'] ) Use :class:`.FetchedValue` to indicate that an already-existing column will generate a default value on the database side which will be available to SQLAlchemy for post-fetch after inserts. This construct does not specify any DDL and the implementation is left to the database, such as via a trigger. .. seealso:: :ref:`server_defaults` - complete discussion of server side defaults :param server_onupdate: A :class:`.FetchedValue` instance representing a database-side default generation function, such as a trigger. This indicates to SQLAlchemy that a newly generated value will be available after updates. This construct does not actually implement any kind of generation function within the database, which instead must be specified separately. .. warning:: This directive **does not** currently produce MySQL's "ON UPDATE CURRENT_TIMESTAMP()" clause. See :ref:`mysql_timestamp_onupdate` for background on how to produce this clause. .. seealso:: :ref:`triggered_columns` :param quote: Force quoting of this column's name on or off, corresponding to ``True`` or ``False``. When left at its default of ``None``, the column identifier will be quoted according to whether the name is case sensitive (identifiers with at least one upper case character are treated as case sensitive), or if it's a reserved word. This flag is only needed to force quoting of a reserved word which is not known by the SQLAlchemy dialect. :param unique: When ``True``, and the :paramref:`_schema.Column.index` parameter is left at its default value of ``False``, indicates that a :class:`_schema.UniqueConstraint` construct will be automatically generated for this :class:`_schema.Column`, which will result in a "UNIQUE CONSTRAINT" clause referring to this column being included in the ``CREATE TABLE`` statement emitted, when the DDL create operation for the :class:`_schema.Table` object is invoked. When this flag is ``True`` while the :paramref:`_schema.Column.index` parameter is simultaneously set to ``True``, the effect instead is that a :class:`_schema.Index` construct which includes the :paramref:`_schema.Index.unique` parameter set to ``True`` is generated. See the documentation for :paramref:`_schema.Column.index` for additional detail. Using this flag is equivalent to making use of the :class:`_schema.UniqueConstraint` construct explicitly at the level of the :class:`_schema.Table` construct itself:: Table( "some_table", metadata, Column("x", Integer), UniqueConstraint("x") ) The :paramref:`_schema.UniqueConstraint.name` parameter of the unique constraint object is left at its default value of ``None``; in the absence of a :ref:`naming convention <constraint_naming_conventions>` for the enclosing :class:`_schema.MetaData`, the UNIQUE CONSTRAINT construct will be emitted as unnamed, which typically invokes a database-specific naming convention to take place. As this flag is intended only as a convenience for the common case of adding a single-column, default configured unique constraint to a table definition, explicit use of the :class:`_schema.UniqueConstraint` construct should be preferred for most use cases, including composite constraints that encompass more than one column, backend-specific index configuration options, and constraints that use a specific name. .. note:: the :attr:`_schema.Column.unique` attribute on :class:`_schema.Column` **does not indicate** if this column has a unique constraint or not, only if this flag was explicitly set here. To view indexes and unique constraints that may involve this column, view the :attr:`_schema.Table.indexes` and/or :attr:`_schema.Table.constraints` collections or use :meth:`_reflection.Inspector.get_indexes` and/or :meth:`_reflection.Inspector.get_unique_constraints` .. seealso:: :ref:`schema_unique_constraint` :ref:`constraint_naming_conventions` :paramref:`_schema.Column.index` :param system: When ``True``, indicates this is a "system" column, that is a column which is automatically made available by the database, and should not be included in the columns list for a ``CREATE TABLE`` statement. For more elaborate scenarios where columns should be conditionally rendered differently on different backends, consider custom compilation rules for :class:`.CreateColumn`. :param comment: Optional string that will render an SQL comment on table creation. .. versionadded:: 1.2 Added the :paramref:`_schema.Column.comment` parameter to :class:`_schema.Column`.
def copy(self, **kw:
Any
) -> Column[ Any]
:
(source)
¶
Undocumented
Indicate if this :class:`.HasCacheKey` instance should make use of the cache key generation scheme used by its immediate superclass. The attribute defaults to ``None``, which indicates that a construct has not yet taken into account whether or not its appropriate for it to participate in caching; this is functionally equivalent to setting the value to ``False``, except that a warning is also emitted. This flag can be set to ``True`` on a particular class, if the SQL that corresponds to the object does not change based on attributes which are local to this class, and not its superclass. .. seealso:: :ref:`compilerext_caching` - General guideslines for setting the :attr:`.HasCacheKey.inherit_cache` attribute for third-party or user defined SQL constructs.
A collection of all :class:`_schema.ForeignKey` marker objects associated with this :class:`_schema.Column`. Each object is a member of a :class:`_schema.Table`-wide :class:`_schema.ForeignKeyConstraint`. .. seealso:: :attr:`_schema.Table.foreign_keys`
The value of the :paramref:`_schema.Column.index` parameter. Does not indicate if this :class:`_schema.Column` is actually indexed or not; use :attr:`_schema.Table.indexes`. .. seealso:: :attr:`_schema.Table.indexes`
sqlalchemy.sql.schema.SchemaItem.info
Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.SchemaItem`. The dictionary is automatically generated when first accessed. It can also be specified in the constructor of some objects, such as :class:`_schema.Table` and :class:`_schema.Column`.
sqlalchemy.sql.elements.ColumnClause.key
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 :class:`_schema.Column` with a ``.key`` of "somekey".
The value of the :paramref:`_schema.Column.unique` parameter. Does not indicate if this :class:`_schema.Column` is actually subject to a unique constraint or not; use :attr:`_schema.Table.indexes` and :attr:`_schema.Table.constraints`. .. seealso:: :attr:`_schema.Table.indexes` :attr:`_schema.Table.constraints`.
Create a copy of this ``Column``, uninitialized. This is used in :meth:`_schema.Table.to_metadata` and by the ORM.
FromClause
, name: Optional[ str]
= None, key: Optional[ str]
= None, name_is_truncatable: bool
= False, compound_select_cols: Optional[ _typing_Sequence[ ColumnElement[ Any]]]
= None, **kw: Any
) -> Tuple[ str, ColumnClause[ _T]]
:
(source)
¶
Create a *proxy* for this column. This is a copy of this ``Column`` referenced by a different parent (such as an alias or select statement). The column should be used only in select scenarios, as its full DDL/default information is not transferred.
merge the elements of another column into this one. this is used by ORM pep-593 merge and will likely need a lot of fixes.
SchemaEventTarget
, *, all_names: Dict[ str, Column[ Any]]
, allow_replacements: bool
, **kw: Any
):
(source)
¶
Associate with this SchemaEvent's parent object.