1.下载第三方驱动
需安装pip 安装方式参考 https://www.cnblogs.com/linyijia/p/12376078.html
2.cmd 打开 并移动到python安装目录的Scripts
cd /d C:\Users\LYJ\AppData\Local\Programs\Python\Python38-32\Scripts
3.输入指令 python3 pip.exe install pyMysql
会看到
在代码中 测试下
import pymysql 没提示错误则代表安装成功
测试MySql是否正常
importpymysql#打开数据库连接
db = pymysql.connect("localhost","root","root","demo")#使用 cursor() 方法创建一个游标对象 cursor
cursor =db.cursor()#使用 execute() 方法执行 SQL 查询
cursor.execute("SELECT VERSION()")#使用 fetchone() 方法获取单条数据.
data =cursor.fetchone()#查看MySql版本
print ("Database version : %s" %data)#关闭数据库连接
db.close()