type
status
date
slug
summary
tags
category
icon
password
标签
是否汉化
python向mysql数据库中插入数据时不报错但是未成功插入的解决办法
- 解决办法
在连接数据库时加上autocommit=True
原因
autocommit的参数必须是True或者False
True:在execute时就会立即向数据库发出操作请求,而不是等待运行到commit()时再一起执行
False:会等到执行commit才会提交
使用True的目的:
保证对Table的新建/删除/插入数据等操作,其位置定位是准确的,也就是说在执行Table操作时整个数据库系统里的所有database名称都是固定的,不存在不确定的情况
离开乏味的皮囊,自由的灵魂在路上
- Name: Alan Hsu
- Tag: 随感、技术、经验、旅行、推荐、生活、音乐、电影 etc.
- Email:xulanzhong521gmail.com
- Twitter:@AlanHsu521
- Telegram:@AlanHsu521
- WeChat: Alan_Hsu_521
- Github: https://github.com/xsoway/
![notion image](https://cdn.jsdelivr.net/gh/xsoway/xmylog_imgs@main/wechat.jpeg?t=b29c016d-83c2-4758-b999-66ade640aee9)
![notion image](https://cdn.jsdelivr.net/gh/xsoway/xmylog_imgs@main/%E5%85%AC%E4%BC%97%E5%8F%B7.jpeg?t=e2596742-b97d-408b-9c5c-2bd4737d9649)
- Author:Alan_Hsu
- URL:https://xmylog.com/article/articles_python_mysql-insert
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!