Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Enhancement request : parametrize internal decode of VARCHAR2 data in Python 3 #162
When there are corrupted data in a VARCHAR2 (for example
With Python 3, there is no way in cx_Oracle (v6.2) to specify the "errors" parameter to the decode() that takes place internally.
It might be nice to be able to
added a commit
Jun 19, 2018
Using code like the following you can now work around bad data in your database. Let me know if that works for you!
def OutputTypeHandler(cursor, name, defaultType, size, precision, scale): if defaultType == cx_Oracle.STRING: return cursor.var(defaultType, size, arraysize = cursor.arraysize, encodingErrors = "replace") cursor.outputtypehandler = OutputTypeHandler cursor.execute("select column1, column2 from SomeTableWithBadData")
The default error handler is "strict" but there are other error handlers besides "replace" which can be seen here: https://docs.python.org/3/library/codecs.html#error-handlers. There is also the possibility of implementing your own error handler. So I'm not sure what "always enabled" would look like!