2

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)

3
  • Maybe look at help.pythonanywhere.com/pages/UsingSQLAlchemywithMySQL Commented Nov 16, 2015 at 14:25
  • @joris Thx, but still doesn't work. If I run the script from within pythonanywhere I get (OperationalError) (1044, "Access denied for user 'user'@'%' to database 'db_name'") 'SHOW TABLES from db_name' () Commented Nov 16, 2015 at 14:29
  • @tobip engine = create_engine('mysql+mysqlconnector://[user]:[pass]@[host]:[port]/[schema]', echo=False) This is full detail you need to connect to a day Commented Nov 16, 2015 at 15:05

1 Answer 1

2

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.

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

2 Comments

Is this the same for Postgres DBs?
That's right -- all databases are on a private subnet.

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.