开发者

How to store count values in python

开发者 https://www.devze.com 2023-02-26 12:25 出处:网络
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.

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

精彩评论

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