Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execute unicode str without parameters #8

Closed
mdobrzanski opened this issue Nov 22, 2011 · 1 comment
Closed

execute unicode str without parameters #8

mdobrzanski opened this issue Nov 22, 2011 · 1 comment
Assignees

Comments

@mdobrzanski
Copy link

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

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

[mssql]
        host = hostname.somedomain
        port = 1433
        tds version = 8.0

unixODBC 2.3.0 odbcinst.ini

[FreeTDS]
Driver          = /usr/local/lib/libtdsodbc.so

[SQLServer]
Driver          = /usr/local/lib/libtdsodbc.so

obdc.ini

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

pyodbc-3.0.2_beta01-py2.6

Select works fine when using
isql

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

or tsql

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

@ghost ghost assigned mkleehammer Sep 27, 2012
@mkleehammer
Copy link
Owner

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants