数据库
首页 > 数据库> > 解决peewee连接mysql库报ImproperlyConfigured: MySQL driver not installed!的问题

解决peewee连接mysql库报ImproperlyConfigured: MySQL driver not installed!的问题

作者:互联网

今天用peewee来连接mysql

from peewee import *
#建立连接mysql时的必要参数
db = MySQLDatabase('student',host ='localhost',user='root',passwd='123456')

db.connect

运行后,spyder一直报错


File "C:\ProgramData\Anaconda3\lib\site-packages\peewee.py", line 3981, in _connect
raise ImproperlyConfigured('MySQL driver not installed!')

ImproperlyConfigured: MySQL driver not installed!

开始以为是pymysql没有配好,于是单独测试pymysql,发现能正常运行,

后按报错信息找到peewee.py的3981行,如下:

 if mysql is None:
     raise ImproperlyConfigured('MySQL driver not installed!')

将这两行注释掉,再测试peewee,不再报错。后尝试连库写表成功

 

标签:peewee,MySQL,driver,installed,ImproperlyConfigured,mysql
来源: https://www.cnblogs.com/zhongciwang/p/14641899.html