1 Star 0 Fork 0

月夜归醉o/python学习笔记

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
write_db.py 586 Bytes
一键复制 编辑 原始数据 按行查看 历史
import pymysql
db = pymysql.connect(host='localhost', port=3306, user='root', passwd='123456', database='test_123', charset='utf8')
# 创建游标
cur = db.cursor()
try:
# 插入操作
sql = "insert into table1 values \
(100,'Jank',28,'1994-12-12');"
cur.execute(sql)
# 修改操作
sql = "update table1 set age=18 where name = 'Frank';"
cur.execute(sql)
# 删除操作
sql = "delete from table1 where age>35;"
cur.execute(sql)
db.commit()
except Exception as e:
db.rollback()
print("Failed:", e)
cur.close()
db.close()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/brozer/python-learning-notes.git
git@gitee.com:brozer/python-learning-notes.git
brozer
python-learning-notes
python学习笔记
master

搜索帮助