Search code examples
mysqlpeewee

PyCharm can't connect to MySQLDatabase, using peewee


My english is not good but I will try to explain my problem. I'm learning peewee and I can't make the connection between mysql and pycharm. This is my code:

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

And it throws the following error:

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

Solution

  • You need to install a database driver:

    $ pip install pymysql