MySQLdb autocommit

MySQLdb 中 autocommit 默认是关闭的,下面是例子。

import MySQLdb


conn = MySQLdb.connect(host='127.0.0.1',user='root',passwd='131417',db='studio');
cursor = conn.cursor();
cursor.execute('select @@autocommit');

data = cursor.fetchone();
print data;

cursor.close();
conn.close();

返回值为 0 ;这个也一定成度上左证了,为什么一定要调用conn.commit()方法。

原文地址:https://www.cnblogs.com/JiangLe/p/4586684.html