如何将Python应用程序与在线数据库连接起来 [英] How to connect python application with online database

查看:53
本文介绍了如何将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应用程序与在线数据库连接起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆