Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Lewis Turner
Lewis Turner
10,930 Points

Connecting to a MAMD mySQL database using peewee

I have installed MAMD on my mac and have setup a mySQL database. I am now attempting to connect to that database in python using peewee. My code is as follows...

import peewee as pw

db = pw.MySQLDatabase('test_database', user='root', passwd='root', host='127.0.0.1', port=8889)
db.connect()

However, I am getting the following error...

peewee.ImproperlyConfigured: MySQLdb or PyMySQL must be installed.

Does anybody have an idea what I am doing wrong?

:o)

1 Answer

Lewis Turner
Lewis Turner
10,930 Points

So, it turns out peewee doesnt come bundled with a MySQL driver. Running "pip install PyMySQL" from Terminal will install a driver and resolve the issue.