To get the first form, you'd create separate queries and turn them into a 
subquery.

(I'm not sure if this would work on a relationship, but this would be the 
form for columns)

    sq_t_queued = 
db.session.query(Task.tasks_queued).count().subquery('t_queued')
    sq_t_running = 
db.session.query(Task.tasks_running).count().subquery('t_running')

Then you'd treat the subqueries as virtual tables:

    q  = db.Session.query(Job).join(sq_t_running, Job.job_id = 
sq_t_running.c.job_id)

There have been a handful of subquery Q&A s over the past month that might 
show a more practical side than the docs.

http://docs.sqlalchemy.org/en/rel_0_9/orm/query.html#sqlalchemy.orm.query.Query.subquery


Query.Count uses a subquery in an example too
http://docs.sqlalchemy.org/en/rel_0_9/orm/query.html#sqlalchemy.orm.query.Query.count
 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to