I have an Ubuntu 13.10 server, Django 1.5 application and Sql Server 2008 and I try to execute a raw query which works fine if it is only without unicode.
Sample Model:
class SomeRecords(models.Model):
EntryName = models.CharField(max_length=20)
Some sample records in the table: (in EntryName field)
['elma', 'armut', 'ıspanak']
elma and armut are not unicode, because it doesn't have special characters, but at ıspanak, there is "ı" letter so it is unicode.
This returns with data: (elma query)
# -*- coding:utf-8 -*-
from django.db import connection, transaction
cursor = connection.cursor()
sql = u"select entryname from somerecords where entryname='elma'"
cursor.execute(sql)
rows=cursor.fetchall()
print len(rows)
And this returns empty: (ıspanak query)
# -*- coding:utf-8 -*-
from django.db import connection, transaction
cursor = connection.cursor()
sql = u"select entryname from somerecords where entryname='ıspanak'"
cursor.execute(sql)
rows=cursor.fetchall()
print len(rows)
So, why the second one returns empty?