当前位置:Gxlcms > 数据库问题 > MySQLdb autocommit

MySQLdb autocommit

时间:2021-07-01 10:21:17 帮助过:2人阅读

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

MySQLdb autocommit

标签:

人气教程排行