I have python code that is making mysql calls. It logs all mysql errors (and sends me a notifiocation on google chat). However warnings such as this dont get reported which makes sense since they are not warnings. I would however like the mysql statement logged when there is a warning so I can fix the underlying issue. What is the best way to find those warnings and get them to the log(with the bad mysql statment
/usr/local/lib/python3.4/dist-packages/pymysql/cursors.py:170: Warning: (1366, "Incorrect string value: '\\xF3n Cha...' for column 'recipient-name' at row 1")
.
try:
cursor.execute(query_string, field_split)
db.commit()
except pymysql.err.InternalError as e:
logger.warning('Mysql Error : %s', e)
logger.warning('Statement : %s', cursor._last_executed)
string_google= str(e.args[1] + ' - ' + cursor._last_executed)
googlechat(string_google)
return #exit rather then marking report run good