Re: [sqlalchemy] Re: group_by argument as a result of a query

2011-08-15 Thread Michael Bayer
On Aug 15, 2011, at 6:03 AM, Eduardo wrote: > This I want to do: > 1) I want to find all names that satisfy this query > column_names = session.query(tab.c.name).filter(tab.c.value==354) > > 2) Among those rows I want to find those with the highest id ( all > rows with the same name are fist gro

Re: [sqlalchemy] Instance is not persistent within this Session

2011-08-15 Thread werner
thanks for the clarification. there's nothing I can see in your practices here that causes that error, it has to do with how you're getting at Session objects in relation to your wx environment. I'd add assertions at every point to ensure that the Session you're getting is the one that you

[sqlalchemy] Re: backref/back_populates question

2011-08-15 Thread cd34
On Aug 15, 1:05 am, Michael Bayer wrote: > A relationship() can be added at any time to any mapped class - when using > declarative config, just assigning it to the class is all that's needed, > mapper.add_property() is called as a result.     Using "backref" where you > had "back_populates" s

[sqlalchemy] Re: group_by argument as a result of a query

2011-08-15 Thread Eduardo
This I want to do: 1) I want to find all names that satisfy this query column_names = session.query(tab.c.name).filter(tab.c.value==354) 2) Among those rows I want to find those with the highest id ( all rows with the same name are fist grouped and only the one with the highest id is retained the

Re: [sqlalchemy] Re: group_by argument as a result of a query

2011-08-15 Thread Wichert Akkerman
On 08/15/2011 10:20 AM, Eduardo wrote: Here is the example: column_names = session.query(tab.c.name).filter(tab.c.value==354) column_names = [column_name for (column_name,) in column_names] query=sess.query(func.max(tab.columns['name']),datab.columns['article_id']).group_by(*column_names).all()

[sqlalchemy] Re: group_by argument as a result of a query

2011-08-15 Thread Eduardo
Here is the example: column_names = session.query(tab.c.name).filter(tab.c.value==354) column_names = [column_name for (column_name,) in column_names] query=sess.query(func.max(tab.columns['name']),datab.columns['article_id']).group_by(*column_names).all() I get an error here: ProgrammingError: