cursor游标方法和属性:
fetchone(): 获取查询结果集的下一行
fetchall(): 获取结果集的所有行
rowcount: 返回受影响的行数
代码示例
import MySQLdb db = MySQLdb.connect("localhost","testuser","test123","TESTDB" ) cursor = db.cursor() sql = 'UPDATE student SET age = age + 1 WHERE sex="man"' cursor.execute(sql) print(cursor.rowcount) # 20 db.close()