2 messages in com.googlegroups.sqlalchemy[sqlalchemy] checking the sql string.
FromSent OnAttachments
SamDonaldson27 May 2007 13:23 
Michael Bayer29 May 2007 14:36 
Subject:[sqlalchemy] checking the sql string.
From:SamDonaldson (samo@gmail.com)
Date:05/27/2007 01:23:02 PM
List:com.googlegroups.sqlalchemy

How do I look to see what sql is being constructed in the query object? So if I have something like:

q = query.session(User) q = q.add_column(....) q = q.group_by(.....).select()

How do I check what sql string has been constructed in q?

Also, say I want to do a group by a particular column name on the User table and I have two aggregates, sum, and count? How do I add these two columns to q? Do I just call add_column twice? It's not working, I'm getting an empty result set.

q = query.session(User) q = q.add_column(func.sum(User.c.id).label('sum')) q = q.add_column(func.count(User.c.id).label('count')) q = q.group_by([User.c.blah]).select()

I'm getting an empty result set. What exactly does label do here?

Thanks.