Manuel
Manuel

Reputation: 31

Using pythonanywhere's MySQL DB in python

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

Upvotes: 1

Views: 289

Answers (1)

Manuel
Manuel

Reputation: 31

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

Upvotes: 2

Related Questions