【文件属性】:
文件名称:关于pymysql模块的使用以及代码详解
文件大小:48KB
文件格式:PDF
更新时间:2021-01-21 18:28:02
charset host mysql
pymysql模块的使用
查询一条数据fetchone()
from pymysql import *
conn = connect(
host='127.0.0.1',
port=3306, user='root',
password='123456',
database='itcast',
charset='utf8')
# 创建游标
c = conn.cursor()
# 执行sql语句
c.execute(select * from student)
# 查询一行数据
result = c.fetchone()
print(result)
# 关闭游标
c.c