Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
想知道是否有办法使用 python 脚本尝试连接到组 mysql 数据库主机?理想情况下,会有 X 台主机,它会尝试连接到每台主机,如果无法建立连接,则会失败。我不相信 MySQLdb.connect 能够处理多个主机,也许我错了。
mysqldb.connect连接到多个主机完全可以:
mysqldb.connect
try: conn1 = mysqldb.connect(...) conn2 = mysqldb.connect(...) ... except: # add specific exception here ... # support failure when connecting