How to connect python application with online database(如何将Python应用程序与在线数据库连接起来)
问题描述
我正在尝试将Python应用程序与在线数据库连接。它在本地主机数据库上工作正常,但当我尝试连接到在线时,它显示错误。
错误
errno=2003, values=(self.get_address(), _strioerror(err)))
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '69.162.107.34:3306' (10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)
代码
import mysql.connector
mydb = mysql.connector.connect(
host="00.00.00.00",
user="user",
passwd="pass",
database="db"
)
mycursor = mydb.cursor()
推荐答案
首先连接工作台,然后重试
这篇关于如何将Python应用程序与在线数据库连接起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!