开发者

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()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜