forgive me, i am not very good at all this stuff, but i'm trying to make something for my boyfriend (programmer) for valentine's day to surprise him. i made a flask app with an app.py that really just displays a render template and connects to a Flask-SQLAlchemy database. i got it deployed on pythonanywhere and it worked fine except for the database since it was tied to my local one. when i tried to do make a new one on the Databases tab, i'm getting errors :(
this is the error when i look at the errors page after trying to reload my app:
sqlalchemy.exc.DatabaseError: (mysql.connector.errors.DatabaseError) 2005 (HY000): Unknown MySQL server host 'l@vesperial.mysql.pythonanywhere-services.com' (-2)
and this is my code in app.py for the database, copied directly from the help page:
SQLALCHEMY_DATABASE_URI = "mysql+mysqlconnector://{username}:{password}@{hostname}/{databasename}".format(
username="vesperial",
password="(password)",
hostname="vesperial.mysql.pythonanywhere-services.com",
databasename="vesperial$coupons",
)
app.config["SQLALCHEMY_DATABASE_URI"] = SQLALCHEMY_DATABASE_URI
app.config["SQLALCHEMY_POOL_RECYCLE"] = 299
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db = SQLAlchemy(app)
i know there are a lot of other forum posts with this issue, i read all i could find but nothing helped. i noticed that, in the error log, it puts the last 1-3 characters of my password at the front of the server host name. you can see it has an "l" in front of the "@vesperial.mysql..." and i don't know why. i changed my password to test this and it's always whatever the last letters of the password are, even though in the file it is exactly as listed on the Database tab. i've tried both pip install mysql-connector-python
and pip install mysqlclient
in the venv
console on pythonanywhere, according to other posts i've found, but it doesn't change the error. if i put my original code with my sqlite3 database, my app works and shows up on the page, just the database doesn't update.
i appreciate any help and i hope you are all having a good day and staying safe.