Pyodbc Exception Args Has Some Unidentified Characters
I am trying to log the pyodbc exception to a log file, the problem is, using the standard python logging, the code produces another exception related to encoding some unidentified
Solution 1:
You can get rid of them by encoding explicitly so that you can use errors="replace"
or ignore
The resulting bytes will not be pretty but they will be logged.
logging.error("Exception: " + str(ex.args[1].encode(encoding='charmap', errors='replace')))
Post a Comment for "Pyodbc Exception Args Has Some Unidentified Characters"