You must fetch the result:
cursor = db.cursor()
count = cursor.execute("SELECT COUNT(*) FROM " + str(table))
db.commit()
print cursor.fetchone()[0]
cursor.close()
Pergunta
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
Solução
You must fetch the result:
cursor = db.cursor()
count = cursor.execute("SELECT COUNT(*) FROM " + str(table))
db.commit()
print cursor.fetchone()[0]
cursor.close()