我试图在pythonanywhere上连接到我的SQL数据库并连接我运行它。
chmod a+x xde-2.22.1-x86_64.AppImage
./xde-2.22.1-x86_64.AppImage
我是通过笔记本电脑执行此操作,并在尝试连接时收到此错误。
import MySQLdb
conn = MySQLdb.connect("MYUSERNAME.mysql.pythonanywhere-services.com","MYUSERNAME","DBPASSWORD","DBTABLENAME")
c = conn.cursor()
c.execute("SELECT * from game_db")
rows = c.fetchall()
for eachrow in rows:
print(eachrow)
我需要进行某种身份验证,还是存在其他问题。 谢谢!
答案 0 :(得分:1)
pythonanywhere mysql服务无法从pythonanywhere外部访问(除非你有一个付费帐户,在这种情况下你可以使用ssh隧道:https://help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere/)