Forums

Can't connect MySQL db provided by pythonanywhere

I am working with my small Flask web app.Now I want to use the Database.After installed MySQLdb follow this tutorial:Using My SQL in Pythonanywhere,I tried these code in Python3.4 shell:

import MySQLdb
host = 'lancaster.mysql.pythonanywhere-services.com'
c = MySQLdb.connect(host=host,user='lancaster',passwd='HERE IS MY DB PASSWORD',db='default')

Then it showed some Error message: Sorry failed to copy from the shell on the website

So how to connect to the database?What goes wrong? Thank you!

After searched the forum,I found this topic: Access Denied to MySQL DB error I changed my db='lancaster$default'.Now it works well.

Yup, that's the way to do it. Database names on PythonAnywhere are of the form "yourusername$the name you specify"