Re: [sqlalchemy] subquery as column

2012-07-25 Thread Michael Bayer
SQLAlchemy has two general classes of SQL construct - the FromClause and the ColumnElement. A FromClause is a thing that goes in the FROM list of a SELECT statement, whereas a ColumnElement goes into the columns clause, WHERE, ORDER BY, GROUP BY, and ON sections of a SELECT statement.A

Re: [sqlalchemy] subquery as column

2012-07-24 Thread Alessandro
Yes,I know, so simple... but it didn't work for me as far I didn't set the label for the internal select. I try it many times, but always without it; I didn't know it was mandatory. Thank you. first_id_row = s.query(Row.id_row).\ filter(Row.id_head ==

Re: [sqlalchemy] subquery as column

2012-07-21 Thread Michael Bayer
from sqlalchemy import Column, Integer from sqlalchemy.orm import Session from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Head(Base): __tablename__ = head id_head = Column(Integer, primary_key=True) class Row(Base): __tablename__ = row

[sqlalchemy] subquery as column

2012-07-19 Thread Alessandro
I have a very simple case: two mapped classes, Head and Row, linked with the id_head id column. This is the primary key for the Head, while id_row is the primary key for the Row table. I'm not able to create the following subqueries: select HEAD.id_head, (select ROW.column_bla_bla from