How to update multiple rows with single MySQL query in python?
问题 #!/usr/bin/python # -*- coding: utf-8 -*- import MySQLdb as mdb con = mdb.connect('localhost', 'root', 'root', 'kuis') with con: cur = con.cursor() cur.execute("UPDATE Writers SET Name = %s WHERE Id = %s ", ("new_value" , "3")) print "Number of rows updated:", cur.rowcount With above code the third row's value of the table Writers in the database kuis gets updated with new_value and the output will be Number od rows updated: 1 How am I supposed to update multiple rows at the same time? 回答1: