简体   繁体   中英

External access to pythonanywhere MySQL database with pandas and SQLAlchemy

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:pass@user.mysql.pythonanywhere-services.com/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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM