【问题标题】:External access to pythonanywhere MySQL database with pandas and SQLAlchemy使用 pandas 和 SQLAlchemy 对 pythonanywhere MySQL 数据库的外部访问
【发布时间】:2016-02-17 16:22:27
【问题描述】:

我想使用pandas 从我的pythonanywhere MySQL 数据库中读取数据。 pandas 使用 sqlalchemy

以下不起作用:

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)

我收到一个错误:OperationalError: OperationalError: (OperationalError) (2003, "Can't connect to MySQL server on 'user.mysql.pythonanywhere-services.com' (10060)") None None

怎么了?或者使用 pythonanywhere 无法进行外部访问? (我是免费计划)

【问题讨论】:

  • @joris Thx,但仍然无法正常工作。如果我从 pythonanywhere 中运行脚本,我会得到 (OperationalError) (1044, "Access denied for user 'user'@'%' to database 'db_name'") 'SHOW TABLES from db_name' ()
  • @tobip engine = create_engine('mysql+mysqlconnector://[user]:[pass]@[host]:[port]/[schema]', echo=False) 这是您连接一天所需的全部详细信息

标签: python mysql pandas sqlalchemy pythonanywhere


【解决方案1】:

PythonAnywhere 在这里开发。不幸的是,您无法从服务外部连接到您的 PythonAnywhere 数据库。如果您有付费计划(带有 SSH 访问权限),那么您可以这样做by using SSH tunnelling,但这不适用于免费帐户。

【讨论】:

  • Postgres 数据库也是这样吗?
  • 没错——所有数据库都在一个私有子网上。
猜你喜欢
  • 2015-05-31
  • 2017-11-03
  • 2017-11-17
  • 2021-03-27
  • 1970-01-01
  • 2015-08-18
  • 2021-06-24
  • 2014-12-21
  • 1970-01-01
相关资源
最近更新 更多