当前位置:网站首页>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()
边栏推荐
- 关联线探究,如何连接流程图的两个节点
- Leetcode 324 swing sort ii[sort double pointer] the leetcode path of heroding
- Linq连表查询
- [stm32 Hal library] RTC and BKP drives
- MSCI 2022 market classification assessment
- [sword finger offer] 50 First character that appears only once
- VSCode里使用条件断点(基于GDB)
- Puma joins hands with 10ktf shop to launch its Web3 cooperation project with the largest scale so far
- Deep virtual memory (VM)
- Understand shell script in one article
猜你喜欢

keil工程,程序写多后,RTT不能打印

Chapter II Classic synchronous exercises

Hit the industry directly | the flying propeller launched the industry's first model selection tool

Keil project, RTT cannot print after too many programs are written

Web API learning notes 1

One card can sell tens of millions, and the business expansion is faster than that of players: you don't understand the Jianghu of star cards

两栏布局左边图片显示部分由右边内容高度决定

【Word 教程系列第 1 篇】如何去除 Word 表格中的箭头

在线文本过滤小于指定长度工具
![[deep learning] (3) encoder mechanism in transformer, complete pytoch code attached](/img/cb/d385bee7a229e8d11f5fa8af66311f.gif)
[deep learning] (3) encoder mechanism in transformer, complete pytoch code attached
随机推荐
ERROR 1067 (42000): Invalid default value for ‘end_time‘ Mysql
在DialogFragment的onStop(完全不可见)时调用dismiss退出界面报错解决办法
第二章 经典同步练习作业
第五章 虚拟存储器 练习
计数排序和排序的稳定性
Undefined symbol main (referred from entry9a.o).
直击产业落地 | 飞桨重磅推出业界首个模型选型工具
Linq连表查询
LINQ linked table query
2022-06-28: what does the following golang code output? A:true; B:false; C:panic; D: Compilation failed. package main import “fm
Deep virtual memory (VM)
Online text filter less than specified length tool
Is the account opening of Guosheng securities really safe and reliable
【Word 教程系列第 1 篇】如何去除 Word 表格中的箭头
Master the usage of const
MATLAB 学习笔记(6)MATLAB 的 upsample 函数和 downsample 函数
Online linear programming: Dual convergence, new algorithms, and regret bounds
Langage C - analyse des mots
【Word 教程系列第 2 篇】Word 中如何设置每页的表格都有表头
Matlab learning notes (6) upsample function and downsample function of MATLAB