PyCharm 无法使用 peewee 连接到 MySQL 数据库

PyCharm can't connect to MySQLDatabase, using peewee

我的英语不好,但我会尽力解释我的问题。我正在学习 peewee,我无法在 mysql 和 pycharm 之间建立联系。这是我的代码:

from peewee import *
db = MySQLDatabase("test", host="localhost", port=3306, user="root", passwd="password")
db.connect()

并抛出以下错误:

AttributeError: 'NoneType' object has no attribute 'connect'

您需要安装数据库驱动:

$ pip install pymysql