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()方法。

posted on 2015-06-18 18:16  蒋乐兴的技术随笔  阅读(544)  评论(0)    收藏  举报

导航