当前位置:网站首页>pymysql.Error 获取错误码与具体错误信息
pymysql.Error 获取错误码与具体错误信息
2022-06-28 23:21:00 【supramolecular】
#-*-coding:utf-8-*-
import pymysql
import time
import traceback
# 打开数据库连接
db = pymysql.connect("127.0.0.1", "root", "123456", "dbname")
# 使用cursor()方法获取操作游标
cursor = db.cursor(cursor=pymysql.cursors.DictCursor)
try:
# 执行sql语句
cursor.execute(sql)
# 提交到数据库执行
db.commit()
# except:
except pymysql.Error as e:
print(e.args[0], e.args[1])
# print(e[0])
# traceback.print_exc()
# 如果发生错误则回滚
# 关闭数据库连接
db.close()
边栏推荐
- [stm32 HAL库] RTC和BKP驱动
- Counting sorting and stability of sorting
- 2022年PMP项目管理考试敏捷知识点(4)
- keil工程,程序写多后,RTT不能打印
- 在线SQL转HTMLTable工具
- What will be done after digital IC Verification?
- YuMinHong set up two funds funded by his hometown
- mysql-5.7.30-winx64免安装版下载安装教程
- Chapter V virtual memory exercise
- C interview questions_ 20220627 record
猜你喜欢

Production environment sonarqube installation
![[matlab] function definition and use](/img/43/a7970ca8e075151277f7773434f7db.png)
[matlab] function definition and use

Machine learning 6-decision tree
![[conception de la machine d'état] Moore, Mealy State Machine, Three - stage, Two - stage, one - stage State Machine Writing Specification](/img/48/e29f34aff7cc437bfb574591d54e3d.png)
[conception de la machine d'état] Moore, Mealy State Machine, Three - stage, Two - stage, one - stage State Machine Writing Specification

ERROR 1067 (42000): Invalid default value for ‘end_time‘ Mysql

Go language - reflect
![[stm32 Hal library] serial port communication](/img/2c/23a2ecf75141b8f38ab99ac6b2eaef.png)
[stm32 Hal library] serial port communication

计数排序和排序的稳定性

华为22级专家十年心血终成云原生服务网格进阶实战文档,是真的6

Linq连表查询
随机推荐
LeetCode 324 擺動排序 II[排序 雙指針] HERODING的LeetCode之路
【OpenCV】—线性滤波:方框滤波、均值滤波、高斯滤波
第四章 存储器管理练习
论文解读(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》
【状态机设计】Moore、Mealy状态机、三段式、二段式、一段式状态机书写规范
mysql-5.7.30-winx64免安装版下载安装教程
Is it safe and reliable to open a securities account in changtou school?
[flutter issues Series title 71] Mutual Conversion between uint8list and Image in flutter
【Word 教程系列第 2 篇】Word 中如何设置每页的表格都有表头
图片64base转码与解码
Master the usage of const
复杂嵌套的对象池(4)——管理多类实例和多阶段实例的对象池
Cmake tutorial (I)
Add the premise of ganggan
Didn't find an internship. He summed it up
【Word 教程系列第 1 篇】如何去除 Word 表格中的箭头
Counting sorting and stability of sorting
[mathematical modeling] fmincon() function of MATLAB nonlinear programming
Leetcode 324 swing sort ii[sort double pointer] the leetcode path of heroding
C interview questions_ 20220627 record