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

Manuel
  • 31
  • 3

1 Answers1

2

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

Manuel
  • 31
  • 3
  • 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. – Rachana Gandhi Mar 03 '20 at 08:10