-
python使用pymysql在mysql的student表查询数据
- 网站名称:python使用pymysql在mysql的student表查询数据
- 网站分类:技术文章
- 收录时间:2025-07-08 14:43
- 网站地址:
“python使用pymysql在mysql的student表查询数据” 网站介绍
import pymysql
# 链接数据库
db = pymysql.connect(host='localhost', port=3306, user='root', password='root', \
db='student_info', charset='utf8')
# 获取游标
cursor = db.cursor()
# sql语句
sql_cmd = "SELECT sno,sname, ssex, sage FROM student WHERE sno = '%s';"
# 数据
data = ('95002',)
# 执行语句
cursor.execute(sql_cmd % data)
# 获取数据
data = cursor.fetchall()
# 打印数据
for item in data:
print("学号:%s;\t姓名:%s;\t性别:%s;\t年龄:%d" % item)
print("共查找出", cursor.rowcount, "条数据")
# 关闭数据库链接
cursor.close()
db.close()
- 最近发表
-
- UpdatePack7R2 24.3.13 补丁包(适合WIN7 2008)
- 磁盘分区对齐详解与配置(磁盘分区分配)
- AndroidStudio_Android使用OkHttp发起Http请求
- 微软官方:2016年1月12日终止旧版IE支持
- 免费让你的win 7获得3年更新!让你的电脑系统重获新生
- AutoCAD各版本对应的R版本参数值及图形的不同版本代号
- C#一行代码搞定OCR(c# readline指定行)
- IE7浏览器明年初退休 Vista又亮了
- 2N3904是什么管?2N3904引脚图和参数+2N3904用途+2种应用实例
- 「操作系统」Windows 7 SP1 旗舰版C大集成更新优化版镜像
- 标签列表
-
- mydisktest_v298 (35)
- sql 日期比较 (33)
- document.appendchild (35)
- 头像打包下载 (35)
- 二调符号库 (23)
- acmecadconverter_8.52绿色版 (25)
- f12019破解 (16)
- 流星蝴蝶剑修改器 (18)
- np++ (17)
- 梦幻诛仙表情包 (36)
- 魔兽模型 (23)
- java面试宝典2019pdf (26)
- beamoff下载 (17)
- disk++ (30)
- vncviewer破解版 (20)
- word文档批量处理大师破解版 (19)
- pk10牛牛 (20)
- 加密与解密第四版pdf (29)
- jemeter官网 (16)
- iteye (26)
- parsevideo (22)
- ckeditor4中文文档 (20)
- centos7.4下载 (32)
- cuda10.1下载 (22)
- intouch2014r2sp1永久授权 (33)