Forums

sqlalchemy error 1045

I'm attempting to merge a pandas DF to a mysql database from within Pythonanywhere.

hostname = "hostname.mysql.pythonanywhere-services.com"
dbname = " 'username$Upwork-RSS' " 
uname = "myusername"
pwd = "mypassword"

engine = create_engine(
    "mysql://{user}:{pw}@{host}/{db}"
    .format(host=hostname, db=dbname, user=uname, pw=pwd))

Error I am receiving is

sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1045, "Access denied for user 'danmeregyourdata'@'10.0.0.187' (using password: YES)") (Background on this error at: http://sqlalche.me/e/e3q8)

I've looked at other similar posts and so far I've tried changing the password, getting rid of the driver (instead of "mysql+pymysql://{user}:{pw}@{host}/{db}" I have "mysql://{user}:{pw}@{host}/{db}")

Where am I going wrong? I got a feeling its something silly.

Those extra spaces and single quotes in the dbname look wrong -- what happens if you change that line to this:

 dbname = "hostname$Upwork-RSS"

...?

I get the same error when I remove the extra quotation mark. I read that the DB Name needs the additional quotation mark, that's why its there. In any case, I've tried with / without the extra marks and with/without the spaces.. same error.

db name on PythonAnywhere is normally username$something, so probably danmergeyourdata$Upwork-RSS in your case

That's what I have in there

    hostname = "danmergeyourdata.mysql.pythonanywhere-services.com"
dbname = "danmergeyourdata$Upwork-RSS"
uname = "danmeregyourdata"
pwd = "*************'

"

Are you 100% sure it's the correct password? You can see the password that you set for your MySQL database in the file .my.cnf in your file storage. If it's the same, can we take a look at your files? We can see them from our admin interface, but we always ask for permission first.

The password is im putting in matches the one in the .my.cnf file. I also just created a whole new database and am still getting the same error.

Are you able to connect to your db from the bash console with mysql command using the same details you use in your code?