I want to use pandas
to read data from my pythonanywhere MySQL database. pandas
uses sqlalchemy
.
The following doesn't work:
import pandas as pd
from sqlalchemy import create_engine
engine = create_engine('mysql://user:[email protected]/user$db_name')
pd.read_sql('SHOW TABLES from db_name', engine)
I'm getting an error: OperationalError: OperationalError: (OperationalError) (2003, "Can't connect to MySQL server on 'user.mysql.pythonanywhere-services.com' (10060)") None None
What's wrong? Or is external access not possible with pythonanywhere? (I'm on a free plan)
PythonAnywhere dev here. Unfortunately you can't connect to your PythonAnywhere database from outside the service. If you had a paid plan (which comes with SSH access) then you could do it by using SSH tunnelling but that won't work from a free account.