| Issue 284: | unicode_results is not honored when connecting to SQL Server Express Edition | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
1. Use django-pyodbc to connect to SQL Server Express Edition running on AWS RDS.
2. Data going in seems to be utf8 encoded properly.
3. Data coming out seems to be decoded as something else and it bubbles back to Django as unicode objects full of garbage where non-ascii characters are supposed to be.
What is the expected output? What do you see instead?
I see strings like 'Jõuülekande osad' instead of 'Jõuülekande osad'.
django-pyodbc connects to the database as:
if self.unicode_results:
self.connection = Database.connect(connstr, \
autocommit=autocommit, \
unicode_results='True')
else:
self.connection = Database.connect(connstr, \
autocommit=autocommit)
In format_results() it has the following code:
for row in rows:
if isinstance(row, str):
fr.append(row.decode('utf-8'))
else:
fr.append(row)
However, cursor.execute() returns nvarchar() columns as unicode objects even though unicode_results = False. By my logic it should return them as str objects so that django-pyodbc can do the proper decoding itself. Why is pyodbc not honoring the unicode_results flag?
What version of the product are you using? On what operating system?
pyodbc version 3.0.6, django-pyodbc is from https://github.com/elver/django-pyodbc
Sep 6, 2012
#1
elver.loho@gmail.com
Sep 26, 2012
Also, when possible, I recommend using Microsoft's driver for Linux instead of FreeTDS. It has significantly fewer problems.
Status:
NoFix
|