I am currently converting my home automation system from MySQL to Influx. With MySQL I have the error checking down pat after using it for so many years.
With MySQL, I can specifically check for database connectivity at the server level, if the correct database exists, if the correct username and password are being used and finally just general DB errors that would prevent my program from running. In each of these cases, I can throw different exceptions and based on the exception send out the proper notification and/or switch to my backup database. If all else fails, it exits my program with a notification since my program is useless without database connectivity.
I was hoping someone could give me some pointers.
MySQL Exception Tracking:
try: cnx = mysql.connector.connect(user=pooldb.username, password=pooldb.password, host=pooldb.servername, database=pooldb.emoncms_db, raise_on_warnings=True) except mysql.connector.Error as err: if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: ...do something here... elif err.errno == errorcode.ER_BAD_DB_ERROR: ...do something here... elif err.errno == errorcode.CR_CONN_HOST_ERROR: ...do something here... else: exit()