I'm trying to connect to my database on PythonAnywhere using the following code:
from sqlalchemy import create_engine
example_str = f'mysql+mysqldb://{user}:{pwd}@{host}/{db}'
# below code modified according to https://help.pythonanywhere.com/pages/UsingSQLAlchemywithMySQL/
engine = create_engine(example_str, pool_recycle=280, pool_pre_ping=True)
conn = engine.connect()
But I keep getting this error: OperationalError: (MySQLdb._exceptions.OperationalError) (2005, "Unknown MySQL server host '('kynnemall.mysql.pythonanywhere-services.com',)' (22)")
Also, when I run the following code in the terminal:
mysql -u kynnemall -h kynnemall.mysql.pythonanywhere-services.com -p kynnemall$default
It hangs for a very long time after I enter the password. What am I doing wrong?