Hi, I'm currently trying to connect to the MySQL db from my local machine and planning to run the Flask/Python file on PythonAnywhere but I'm getting an error.
What I have:
import MySQLdb # I have the actual credentials, just changed for this forum post username = 'username' password = 'pass' hostname = 'username.mysql.pythonanywhere-services.com' db = 'username$zipcodes' conn = MySQLdb.connect(host=hostname, user=username, passwd=password, db=db) cursor = conn.cursor() #cursor.execute('SELECT * from ') #row = cursor.fetchone() conn.close() print(conn) print("asdf")
MySQLdb._exceptions.OperationalError: (2002, "Can't connect to MySQL server on 'username.mysql.pythonanywhere-services.com' (10060)")
I've referred to this and other links (https://www.pythonanywhere.com/forums/topic/2477/) but I don't know where I'm going wrong here. If MySQLdb isn't viable, then what's the simplest way to interact with the MySQL database?