Reputation: 441
Wondering if there is a way to use a python script to attempt a connection to a group mysql database hosts? Ideally there would be X number of hosts and it would try connecting to each, then fail if no connection could be made. I do not believe MySQLdb.connect is capable of handling multiple hosts, maybe I am wrong.
Upvotes: 2
Views: 889
Reputation: 137460
mysqldb.connect
is perfectly ok with connecting to multiple hosts:
try:
conn1 = mysqldb.connect(...)
conn2 = mysqldb.connect(...)
...
except: # add specific exception here
... # support failure when connecting
Upvotes: 3