Usage of “aliased” in SQLAlchemy ORM

后端 未结 2 948
无人共我
无人共我 2021-01-01 17:04

From the SQLAlchemy ORM Tutorial:

You can control the names using the label() construct for scalar attributes and aliased for class constructs:

2条回答
  •  旧时难觅i
    2021-01-01 17:30

    aliased() or alias() are used whenever you need to use the SELECT ... FROM my_table my_table_alias ... construct in SQL, mostly when using the same table more than once in a query (self-joins, with or without extra tables). You also need to alias subqueries in certain cases.

    There's an example in the documentation: http://www.sqlalchemy.org/docs/orm/query.html?highlight=aliased#sqlalchemy.orm.util.AliasedClass

提交回复
热议问题