Aggregate funuctions broken in MySQLdb?

Lorenzo Thurman lorenzo at nospamthethurmans.com
Mon May 15 15:51:14 EDT 2006


Thanks, that was my problem. Can you point me to some documentation on 
MySQLdb? I've been googling to get answers and that obviously has not 
been working.




In article <1147623011.319336.11820 at v46g2000cwv.googlegroups.com>,
 "Wade Leftwich" <wleftwich at gmail.com> wrote:

> Works fine for me, and I certainly hope MySQLdb is ready for prime
> time, because I use the heck out of it. Maybe you're getting fooled by
> the fact that cursor.execute() returns the count of result rows. To
> actually see the result rows, you have to say cursor.fetchone() or
> fetchall() --
> 
> In [34]: cur.execute("select article_id from articles limit 10")
> Out[34]: 10L
> 
> In [35]: cur.fetchall()
> Out[35]: ((3L,), (4L,), (5L,), (6L,), (7L,), (8L,), (9L,), (10L,),
> (11L,), (12L,))
> 
> In [36]: cur.execute("select count(article_id) from articles where
> article_id < 13")
> Out[36]: 1L
> 
> In [37]: cur.fetchall()
> Out[37]: ((10L,),)
> 
> In [38]: cur.execute("select sum(article_id) from articles where
> article_id < 13")
> Out[38]: 1L
> 
> In [39]: cur.fetchone()
> Out[39]: (75.0,)
> 
> In [40]: cur.execute("select avg(article_id) from articles where
> article_id < 13")
> Out[40]: 1L
> 
> In [41]: cur.fetchone()
> Out[41]: (7.5,)



More information about the Python-list mailing list