1

I've created a MySQL DB on pythonanywhere.com. Now I'm writing a python script on my local PC trying to connect to it, but can't establish a connection.

import pyodbc

with pyodbc.connect(DRIVER="{MySQL ODBC 8.0 Unicode Driver}",
                    SERVER="******.mysql.pythonanywhere-services.com",
                    DATABASE="******$default",
                    USER="******",
                    PASSWORD="******",
                    OPTION="3") as conn:
    cursor = conn.cursor()

Same with this connection string format:

pyodbc.connect("""DRIVER={MySQL ODBC 8.0 Unicode Driver};SERVER=******.mysql.pythonanywhere-services.com;DATABASE=******$default;USER=******;PASSWORD=******""")

****** = censored username and password

It returns this error:

pyodbc.Error: ('HY000', "[HY000] [MySQL][ODBC 8.0(w) Driver]Can't connect to > MySQL server on '******.mysql.pythonanywhere-services.com' (10060) (2003) (SQLDriverConnect); [HY000] [MySQL][ODBC 8.0(w) Driver]Can't connect to MySQL > server on '******.mysql.pythonanywhere-services.com' (10060) (2003)")

The official documentation doesn't seem to tackle this problem. It only mentions the library mysqlclient but I can't find out what it's purpose is.

Edit: It's only possible via ssh/paid account Accessing your MySQL database from outside PythonAnywhere

2
  • Please consider posting your update as an answer to make it easier for others to find the solution. Commented Oct 12, 2019 at 11:15
  • Thanks for the info. Just did so. Commented Oct 13, 2019 at 17:16

1 Answer 1

2

Found the answer on the site. It's only possible via ssh/paid account Accessing your MySQL database from outside PythonAnywhere

Sign up to request clarification or add additional context in comments.

1 Comment

Did you buy the plan or did you host it somewhere else? I am in the same situation right now and I am trying to find a Python Flask-capable Webhost which supports pyodbc for free, as my project is a demo currently.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.