Frage

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

War es hilfreich?

Lösung

You must fetch the result:

cursor = db.cursor()
count = cursor.execute("SELECT COUNT(*) FROM " + str(table))
db.commit()
print cursor.fetchone()[0]
cursor.close()
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top