MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / ColumnClause

Class ColumnClause

lib/sqlalchemy/sql/elements.py:4905–5159  ·  view source on GitHub ↗

Represents a column expression from any textual string. The :class:`.ColumnClause`, a lightweight analogue to the :class:`_schema.Column` class, is typically invoked using the :func:`_expression.column` function, as in:: from sqlalchemy import column id, name = column(

Source from the content-addressed store, hash-verified

4903
4904
4905class ColumnClause(
4906 roles.DDLReferredColumnRole,
4907 roles.LabeledColumnExprRole[_T],
4908 roles.StrAsPlainColumnRole,
4909 Immutable,
4910 NamedColumn[_T],
4911):
4912 """Represents a column expression from any textual string.
4913
4914 The :class:`.ColumnClause`, a lightweight analogue to the
4915 :class:`_schema.Column` class, is typically invoked using the
4916 :func:`_expression.column` function, as in::
4917
4918 from sqlalchemy import column
4919
4920 id, name = column("id"), column("name")
4921 stmt = select(id, name).select_from("user")
4922
4923 The above statement would produce SQL like:
4924
4925 .. sourcecode:: sql
4926
4927 SELECT id, name FROM user
4928
4929 :class:`.ColumnClause` is the immediate superclass of the schema-specific
4930 :class:`_schema.Column` object. While the :class:`_schema.Column`
4931 class has all the
4932 same capabilities as :class:`.ColumnClause`, the :class:`.ColumnClause`
4933 class is usable by itself in those cases where behavioral requirements
4934 are limited to simple SQL expression generation. The object has none of
4935 the associations with schema-level metadata or with execution-time
4936 behavior that :class:`_schema.Column` does,
4937 so in that sense is a "lightweight"
4938 version of :class:`_schema.Column`.
4939
4940 Full details on :class:`.ColumnClause` usage is at
4941 :func:`_expression.column`.
4942
4943 .. seealso::
4944
4945 :func:`_expression.column`
4946
4947 :class:`_schema.Column`
4948
4949 """
4950
4951 table: Optional[FromClause]
4952 is_literal: bool
4953
4954 __visit_name__ = "column"
4955
4956 _traverse_internals: _TraverseInternalsType = [
4957 ("name", InternalTraversal.dp_anon_name),
4958 ("type", InternalTraversal.dp_type),
4959 ("table", InternalTraversal.dp_clauseelement),
4960 ("is_literal", InternalTraversal.dp_boolean),
4961 ]
4962

Callers 5

literal_columnFunction · 0.85
_make_proxyMethod · 0.85
columnsMethod · 0.85
_make_proxyMethod · 0.85
columnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected