Mysql exceptions (#1397)

* update for correct exception names for mysqlclient library

* commit database on shutdown
This commit is contained in:
Michel Oosterhof 2020-08-10 21:19:30 +08:00 committed by GitHub
parent 35c12dc14c
commit 049ac85493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -31,7 +31,7 @@ class ReconnectingConnectionPool(adbapi.ConnectionPool):
try:
return adbapi.ConnectionPool._runInteraction(
self, interaction, *args, **kw)
except MySQLdb.OperationalError as e:
except (MySQLdb.OperationalError, MySQLdb._exceptions.OperationalError) as e:
if e.args[0] not in (2003, 2006, 2013):
raise e
log.msg("RCP: got error {0}, retrying operation".format(e))
@ -65,10 +65,11 @@ class Output(cowrie.core.output.Output):
cp_reconnect=True,
use_unicode=True
)
except MySQLdb.Error as e:
except (MySQLdb.Error, MySQLdb._exceptons.Error) as e:
log.msg("output_mysql: Error %d: %s" % (e.args[0], e.args[1]))
def stop(self):
self.db.commit()
self.db.close()
def sqlerror(self, error):