How to store count values in python
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?
cursor.fetchone()
gives you the result directly..so no need to take its zeroeth element..what you want is given to you directly when you say:
row = cur1.fetchone()
精彩评论