#!/usr/bin/env python #--*-- coding:utf-8 --*-- __author__ = 'Kevin' import MySQLdb as mdb import sys con = mdb.connect('localhost','root','redhat','test') try: with con: cur = con.cursor() cur.execute("UPDATE Writers SET Name = %s WHERE Id = %s",("Guy de Maupasant","3")) print "Number of rows updated: %d" % cur.rowcount finally: con.close()
Result:python
Number of rows updated: 1