mysqldb SELECT COUNT reurns 1

Rob Williscroft rtw at freenet.co.uk
Thu Dec 27 15:24:11 EST 2007


SMALLp wrote in news:fl10ev$hfb$1 at ss408.t-com.hr in comp.lang.python:

> Hy! I nave another problem I can't solve!
> <code>
> 
>      import MySQLdb as mysql

> cursor = conn.cursor()
> sql = "SELECT COUNT(*) FROM " + dataTable
> res = cursor.execute(sql)

I think you need to do:
res = cursor.fetchone()[0]


> print res
> 
> <code>
> It prints 1, and there are 88 rows in table. SELECT works fine, but 
> SELECT COUNT(*) makes problems.
 
Rob.
-- 
http://www.victim-prime.dsl.pipex.com/



More information about the Python-list mailing list