如何在Python中存储计数值
我想根据两个表的总行数来比较它们。所以我使用 count(*) 来计算两个表中的总行数。
我的代码是:
cur1.execute ("""SELECT COUNT(*) FROM mytable;""")
为了存储此查询返回的总计数,
我使用了
row = cur1.fetchone()
result1 = row[0]
但它没有帮助。有人可以建议我解决方案吗?
I want to compare two tables based on their total number of rows. So i use count(*) to count the total number of rows in both table.
My code is:
cur1.execute ("""SELECT COUNT(*) FROM mytable;""")
In order to store the total count return by this query,
I use
row = cur1.fetchone()
result1 = row[0]
but it didn't help. Can anyone suggest me the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
直接给你结果..所以不需要取它的第零个元素..当你说:
gives you the result directly..so no need to take its zeroeth element..what you want is given to you directly when you say: