我试图在python中打印计数表,我写这段代码:
count = cur.execute("SELECT COUNT(*) FROM %s;" str(table))
print count
所有打印结果都是1,(想想1 =真),我怎样才能打印出我的sql命令的真实结果?
感谢
答案 0 :(得分:3)
您必须获取结果:
cursor = db.cursor()
count = cursor.execute("SELECT COUNT(*) FROM " + str(table))
db.commit()
print cursor.fetchone()[0]
cursor.close()