Where is the SQLAlchemy documentation for ".c". attribute for accessing columns by name in a query or table?

I saw some links in the SQLAlchemy Documentation for the .c. attribute .c. (see the following examples). Where the SQLAlchemy documentation describes this .c. attribute .c. ? (for example, on what objects is this attribute available?)

Link examples:

  • " Expression system users know that Select.apply_labels() adds a table name to each column name, affecting the names available from Select.c "
  • " Available columns in the statement through the c attribute:
    >>> for u, count in session.query(User, stmt.c.address_count).\
    ... outerjoin(stmt, User.id==stmt.c.user_id).order_by(User.id):
    ... print u, count
  • mapper(User, user, properties={
    'addresses' : relationship(Address, backref='user', order_by=address.c.id)
    }) #link
  • " SQL expressions are usually specified in terms of Table objects, that is, address.c.id above for the Address relationship, not Address.id , because Address cannot yet be bound to table metadata, and we cannot specify a string here. "
  • When matching with an existing table , a column object can be referenced directly: "
    class User(Base):
    __table__ = user_table
    id = user_table.c.user_id
    name = user_table.c.user_name
  • Here is an example of Postgresql WITH RECURSIVE . Note that in this example, the aliases included_parts cte and incl_alias are key selections, which means that the columns are accessed through the .c. attribute .c. .
+7
documentation attributes sqlalchemy
source share
1 answer

c is an alias for the columns attribute, and it is available for Select Expressions, Tables, Table Expressions and From Clause Expressions objects Select Expressions, Tables, Table Expressions and From Clause Expressions and possibly other classes.

c or columns is a collection of all available columns. An example of the c attribute described in the docs:

c
inherited from c-attribute FromClause
Alias ​​for the columns attribute.

The following sqlalchemy documentation search shows all classes with c or columns as an attribute, including several that I did not know about before:

http://docs.sqlalchemy.org/en/rel_0_9/search.html?q=.columns&check_keywords=yes&area=default#

What I found really cool was that you can turn a simple TextClause object into a TextAsFrom object

http://docs.sqlalchemy.org/en/rel_0_9/core/sqlelement.html?highlight=.columns#sqlalchemy.sql.expression.TextClause.columns

+3
source share

All Articles