- Python操作MySQL步骤
import pymysql
# 创建连接对象
conn = pymysql.connect(host="", port=3306, user="root", password="123456", database="demo", charset="utf8")
# 建立游标
cur = conn.cursor()
# 查询SQL语句
sql = "select * from user"
# 执行语句
count = cur.execute(sql)
# 获取结果
one_ret = cur.fetchone() # 获取一条
for ret in cur.fetchall(

最低0.47元/天 解锁文章
220

被折叠的 条评论
为什么被折叠?



