[sqlalchemy] Re: Generative group_by query specify columns

2007-08-28 Thread Curtis Scheer
So why is it possible do a query.group_by() but not a possible to specify
the columns to select as execution of the query fails in postgresql because
it is trying to select all the columns of table Foo in this instance.

Or is their some way of combining the sql.select() module with the query
module?

 

  _  

From: Michael Bayer [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 24, 2007 7:14 PM
To: sqlalchemy@googlegroups.com
Subject: [sqlalchemy] Re: Generative group_by query specify columns

 

 

On Aug 24, 2007, at 10:43 AM, Curtis Scheer wrote:





What is the syntax to specify the columns in a generative query?

q = session.query(Foo)

q = q.group_by([foo_table.c.description])

for currow in q:

print currow

This query selects all the columns in the Foo table, wondering how to
specify the columns to select.

 

query(Foo) will always select all columns that correspond to a Foo object.
for individual columns, use a SQL expression instead of a Query, i.e.
select([foo_table.c.cola,
foo_table.c.colb]).group_by(...).where(...).etc() .





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Generative group_by query specify columns

2007-08-24 Thread Michael Bayer

On Aug 24, 2007, at 10:43 AM, Curtis Scheer wrote:

 What is the syntax to specify the columns in a generative query?



 q = session.query(Foo)

 q = q.group_by([foo_table.c.description])



 for currow in q:

 print currow



 This query selects all the columns in the Foo table, wondering how  
 to specify the columns to select.

query(Foo) will always select all columns that correspond to a Foo  
object.  for individual columns, use a SQL expression instead of a  
Query, i.e. select([foo_table.c.cola, foo_table.c.colb]).group_by 
(...).where(...).etc() .
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---