im trying to print count table in python, im write this code:

count = cur.execute("SELECT COUNT(*) FROM %s;" str(table))
print count

all print results is 1, (think 1 = true), how i can print the real result of my sql command ?

thanks

有帮助吗?

解决方案

You must fetch the result:

cursor = db.cursor()
count = cursor.execute("SELECT COUNT(*) FROM " + str(table))
db.commit()
print cursor.fetchone()[0]
cursor.close()
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top