I use the mysql plugin to connect to a mysql database (hence the name…)
But, because the mysql instance is created in code, I don’t have events on the mysql plugin.
I cannot find it in the documentation, but is there a way to get informed when the connection is lost? So that I can reconnect?
But one thing left: mysql doens’t seem to have any events. Is that normal?
Even the parent object “Database” doesn’t seem to have any events. This asks for a feature request I think.
No idea about that since I have never used the mysql plugin, sorry. I thought you were saying that there were events available but you could’t use them because you were initiating via code (the perfect situation to use addhandler). If there are no events available maybe there is a connected property or a method to check if the DB is connected? Just check that with a timer periodically and if it’s disconnected trigger your reconnect code.
I usually just attempt a database action and check the error that comes back. If it indicates the connection is lost, I reconnect and retry the db action.