[BangPypers] convert a query to SQLAlchemy

Baiju M baiju.m.mail at gmail.com
Sun Jan 30 04:43:07 CET 2011


Hi,

Can any one help me to convert this query to SQLAlchemy sytax ?

  select * from distributions inner join (select * from comments where
  comments.id in (select max(comments.id) as id from comments group by
  comments.distribution_id)) a on distributions.id = a.distribution_id
  order by a.datetime desc

The schema is here:
https://github.com/baijum/getpython3/blob/master/py3k/model.py
May be the query can be simplified.

Regards,
Baiju M


More information about the BangPypers mailing list