Question

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

Was it helpful?

Solution

You must fetch the result:

cursor = db.cursor()
count = cursor.execute("SELECT COUNT(*) FROM " + str(table))
db.commit()
print cursor.fetchone()[0]
cursor.close()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top