Forums

using flask-migrate on pythonanywhere

In my flask application, I am using flask-migrate. While developing locally, I have created migration file. I have uploaded the migration folder on pythonanywhere. I have all the dependencies correctly installed. My database on pythonanywhere is correctly configured.

On pythonanywhere bash command prompt, I have activated the virtual environment where flask-migrate is installed. I set the FLASK_APP variable correctly. Finally when, running the command:

flask db upgrade

Now I am getting the error:

(1044, "Access denied for user 'prrbusinessbook'@'%' to database 'pms_db'")

I understand that mysql database on pythonanywhere can not be connected without ssh. But then how can I use flask-migrate on pythonanywhere?

It looks more like a password error. When you're developing locally you will not be sshing when connecting to the database, the db lives in a file in your project. I can't see the .sqlite file so you might want to check if you are creating the database correctly and can log in the database via the bash console

If I connect to sqlite3 database, the migration is correctly done and sqlite database file is created on pythonanywhere. But when trying to connect MySQL database created on pythonanywhere, I am getting the above error.

Make sure that you are using the username that is shown on your Databases page and the password that you set there when you initialised your MySQL database. Also make sure that you use the correct name for the database - databases on PythonAnywhere all have a '$' in the name.