execute unicode str without parameters #8

mdobrzanski opened this Issue Nov 22, 2011 · 1 comment


None yet

2 participants


When using unicode query string, query doesn't execute.

import pyodbc
con = pyodbc.connect('DSN=Northwind; UID=vte; PWD=vte')
res = con.cursor().execute(u"select * from Customers where CustomerID = 'ĄŁÓ$!'").fetchall()
print len(res)
#output: 0, should be 1

When encoding query string utf-8 the result is the same - 0

My configuration on Ubuntu 10.04

FreeTDS 0.91 freetds.conf

        # TDS protocol version
        tds version = 8.0
        client charset = UTF-8
        text size = 64512

        host = hostname.somedomain
        port = 1433
        tds version = 8.0

unixODBC 2.3.0 odbcinst.ini

Driver          = /usr/local/lib/libtdsodbc.so

Driver          = /usr/local/lib/libtdsodbc.so


Description = MS SQL Database
Driver      = FreeTDS
Servername  = mssql
Database    = Northwind
UID     = 
PWD     = 
Port        = 1433


Select works fine when using

isql Northwind vte vte
select * from Customers where CustomerID = 'ĄŁÓ$!'

or tsql

tsql -S mssql -U vte -P vte
use Northwind
select * from Customers where CustomerID = 'ĄŁÓ$!'

@mkleehammer mkleehammer was assigned Sep 27, 2012

I realize this is a year old, but I had not been watching for Github issues, only the Google Code issues. Sorry about that.

Assuming anyone is still interested, my first guess is that UCS2 would be a better choice for SQL Server. I don't think it is expecting UTF8.

I'm going to close this just because it is so old, but please reopen if this is still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment