django-pyodbc-azure
django-pyodbc-azure copied to clipboard
Handle decode charset error
base.py line 561 - 571
def format_row(self, row):
"""
Decode data coming from the database if needed and convert rows to tuples
(pyodbc Rows are not sliceable).
"""
if self.driver_charset:
for i in range(len(row)):
f = row[i]
# FreeTDS (and other ODBC drivers?) doesn't support Unicode
# yet, so we need to decode utf-8 data coming from the DB
if isinstance(f, binary_type):
row[i] = f.decode(self.driver_charset)
return row
In case fail to decode, it raise error.
What if we decode with error ignore option like f.decode(self.driver_charset, errors ='ignore')
If you need, I am going to make PR.
getting this error: is it related?
UnicodeDecodeError: 'utf-16-le' codec can't decode bytes in position 22-23: unexpected end of data
@sean29 Were you able to solve this?
Edit: I was getting this because of inputting invalid value in the geography field in MSSQL database