1、离线安装pymysql
下载pychar
官网:[https://pypi.org/project/PyMySQL/](https://pypi.org/project/PyMySQL/)
PyMySQL-0.9.3.tar.gz
安装:
pip3 install PyMySQL-0.9.3.tar.gz
2、pycharm更新包
重新设置项目的interpreter,设置为python的安装目录即可
3、测试源码
import pymysql
conn = pymysql.Connect(
host='127.0.0.1',
port=3306,
user='root',
password='111111',
database='1111',
charset='utf8'
)
cursor = conn.cursor()
sql = 'select * from com_version'
cursor.execute(sql)
ret = cursor.fetchone()
cursor.close()
conn.close()
print(ret)