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.