我正在通过连接到2个数据库mysql.connect在
oldCnx = mysql.connector.connect(user='root', password='root', host='127.0.0.1', database='testdb', connect_timeout=10000)
以相同的方式连接到远程数据库集(仅使用其他凭据)。20(或60)分钟后,我得到错误:mysql.connector.errors.OperationalError: 2055: Lost connection to MySQL server at '127.0.0.1:3306', system error: 10054. An existing connection was forcibly closed by the remote host
。在
怎么办?当连接被强制关闭时,我需要以某种方式扩展超时还是重新连接?如果是,我该怎么做?在
如果您想修改超时,可以在} 参数
connect()
中使用^{在try/except块中使用^{} 也可以重新连接。在
相关问题 更多 >
编程相关推荐