Hook PyMSQL errors

Please post any questions about developing your plugin here. Please use the search function before posting!
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Hook PyMSQL errors

Postby decompile » Thu Jun 30, 2016 3:36 pm

Hey, How can I hook some PyMYSQL errors so I can lets say let it reconnect- or just print a server message with (MySQL Connection Lost.)?

I just found that my server is rare'ly just timing out, which gives some error messages in console:

Code: Select all

pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')


Code: Select all

TimeoutError: [WinError 10060] Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat


Code: Select all

pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'xx' ([Errno 11002] getaddrinfo failed)")


Do I need to modify the pymysql package or can I do it with an own written script.
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Hook PyMSQL errors

Postby Ayuto » Thu Jun 30, 2016 4:01 pm

Just catch the exceptions using try/except.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 42 guests