[sqlalchemy] Re: sqlalchemy with turbogears and assign_mapper: group_by

2007-09-11 Thread Lukasz Szybalski

On 9/10/07, Roger Demetrescu [EMAIL PROTECTED] wrote:

 On 9/8/07, Lukasz Szybalski [EMAIL PROTECTED] wrote:
 
  On 9/7/07, Paul Johnston [EMAIL PROTECTED] wrote:
  
   Hi,
  
   And if I wanted to select a year and group by year?
   select User.Year from User group by User.Year
db.execute(select([User.Year]) ???
   
   
   Have a look at http://www.sqlalchemy.org/docs/04/sqlexpression.html
  
  Ok.
  Based on documentation.
  I do:
  import sqlalchemy
s2=sqlalchemy.select([User.c.YEAR])
  s3=s2.execute()
 
  Got all year fields. 1995,1995,1995,1996,1996..
  Now I want to group so I get just one.
s2=sqlalchemy.select([User.c.YEAR]).group_by(User.c.YEAR)
  But when I execute, I get:
  s3=s2.execute()
 
  Traceback (most recent call last):
File console, line 1, in ?
  AttributeError: 'NoneType' object has no attribute 'execute'
 
  In docs they use conn.execute(s2)
  Is this a different execute that is being called from somewhere else?

 I didn't read this thread from the beginning, but if you are using TG,
 probably you are using SA = 0.3.10, which means you don't have
 generative select() constructs...

 So you'll need to modify your code to (not tested):

 s2=sqlalchemy.select([User.c.YEAR], group_by=[User.c.YEAR])
 s3=s2.execute()

That has worked.
Thanks.
Lucas

--~--~-~--~~~---~--~~
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: sqlalchemy with turbogears and assign_mapper: group_by

2007-09-11 Thread Lukasz Szybalski

Hi,
   
And if I wanted to select a year and group by year?
select User.Year from User group by User.Year
 db.execute(select([User.Year]) ???


Have a look at http://www.sqlalchemy.org/docs/04/sqlexpression.html
   
   Ok.
   Based on documentation.
   I do:
   import sqlalchemy
 s2=sqlalchemy.select([User.c.YEAR])
   s3=s2.execute()
  
   Got all year fields. 1995,1995,1995,1996,1996..
   Now I want to group so I get just one.
 s2=sqlalchemy.select([User.c.YEAR]).group_by(User.c.YEAR)
   But when I execute, I get:
   s3=s2.execute()
  
   Traceback (most recent call last):
 File console, line 1, in ?
   AttributeError: 'NoneType' object has no attribute 'execute'
  
   In docs they use conn.execute(s2)
   Is this a different execute that is being called from somewhere else?
 
  I didn't read this thread from the beginning, but if you are using TG,
  probably you are using SA = 0.3.10, which means you don't have
  generative select() constructs...
 
  So you'll need to modify your code to (not tested):
 
  s2=sqlalchemy.select([User.c.YEAR], group_by=[User.c.YEAR])
  s3=s2.execute()

 That has worked.

How do I add the where statement to it?

 s2=sqlalchemy.select([Userl.c.CITY], group_by=[User.c.CITY],
User.c.YEAR=='1980')
SyntaxError: non-keyword arg after keyword arg


Lucas

--~--~-~--~~~---~--~~
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: sqlalchemy with turbogears and assign_mapper: group_by

2007-09-11 Thread Lukasz Szybalski

On 9/11/07, Lukasz Szybalski [EMAIL PROTECTED] wrote:
 Hi,

 And if I wanted to select a year and group by year?
 select User.Year from User group by User.Year
  db.execute(select([User.Year]) ???
 
 
 Have a look at http://www.sqlalchemy.org/docs/04/sqlexpression.html

Ok.
Based on documentation.
I do:
import sqlalchemy
  s2=sqlalchemy.select([User.c.YEAR])
s3=s2.execute()
   
Got all year fields. 1995,1995,1995,1996,1996..
Now I want to group so I get just one.
  s2=sqlalchemy.select([User.c.YEAR]).group_by(User.c.YEAR)
But when I execute, I get:
s3=s2.execute()
   
Traceback (most recent call last):
  File console, line 1, in ?
AttributeError: 'NoneType' object has no attribute 'execute'
   
In docs they use conn.execute(s2)
Is this a different execute that is being called from somewhere else?
  
   I didn't read this thread from the beginning, but if you are using TG,
   probably you are using SA = 0.3.10, which means you don't have
   generative select() constructs...
  
   So you'll need to modify your code to (not tested):
  
   s2=sqlalchemy.select([User.c.YEAR], group_by=[User.c.YEAR])
   s3=s2.execute()
 
  That has worked.

 How do I add the where statement to it?

  s2=sqlalchemy.select([Userl.c.CITY], group_by=[User.c.CITY],
 User.c.YEAR=='1980')
 SyntaxError: non-keyword arg after keyword arg

Sorry for so many email.
Reverse order did just fine.
s2=sqlalchemy.select([Userl.c.CITY],User.c.YEAR=='1980', group_by=[User.c.CITY])

Thanks


http://lucasmanual.com/mywiki/TurboGears#head-efa212e209e018777039812dbfc86006f6330677

--~--~-~--~~~---~--~~
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: sqlalchemy with turbogears and assign_mapper: group_by

2007-09-10 Thread Roger Demetrescu

On 9/8/07, Lukasz Szybalski [EMAIL PROTECTED] wrote:

 On 9/7/07, Paul Johnston [EMAIL PROTECTED] wrote:
 
  Hi,
 
  And if I wanted to select a year and group by year?
  select User.Year from User group by User.Year
   db.execute(select([User.Year]) ???
  
  
  Have a look at http://www.sqlalchemy.org/docs/04/sqlexpression.html
 
 Ok.
 Based on documentation.
 I do:
 import sqlalchemy
   s2=sqlalchemy.select([User.c.YEAR])
 s3=s2.execute()

 Got all year fields. 1995,1995,1995,1996,1996..
 Now I want to group so I get just one.
   s2=sqlalchemy.select([User.c.YEAR]).group_by(User.c.YEAR)
 But when I execute, I get:
 s3=s2.execute()

 Traceback (most recent call last):
   File console, line 1, in ?
 AttributeError: 'NoneType' object has no attribute 'execute'

 In docs they use conn.execute(s2)
 Is this a different execute that is being called from somewhere else?

I didn't read this thread from the beginning, but if you are using TG,
probably you are using SA = 0.3.10, which means you don't have
generative select() constructs...

So you'll need to modify your code to (not tested):

s2=sqlalchemy.select([User.c.YEAR], group_by=[User.c.YEAR])
s3=s2.execute()


Cheers,

Roger

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---