Python: Number of rows affected by cursor.execute("SELECT …)

前端 未结 6 1362
迷失自我
迷失自我 2020-12-13 08:36

How can I access the number of rows affected by:

cursor.execute(\"SELECT COUNT(*) from result where server_state=\'2\' AND name LIKE \'\"+digest+\"_\"+charse         


        
6条回答
  •  醉梦人生
    2020-12-13 09:08

    To get the number of selected rows I usually use the following:

    cursor.execute(sql)
    count = (len(cursor.fetchall))
    

提交回复
热议问题