Skip to Content.
Sympa Menu

freetds - [freetds] Python Unicode SQL Statements

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Michael Trier <mtrier AT gmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Python Unicode SQL Statements
  • Date: Mon, 4 May 2009 21:03:25 -0400

Hello,
I've wrestled with this for several days now and I'm at a loss for
understanding how to make this work. I have the following test script:

import pyodbc
conn =
pyodbc.connect("Driver=FreeTDS;Servername=vm;UID=sprint;PWD=sprint;Database=sprint;")
cursor = conn.cursor()
sql = u"SELECT * FROM test_table;"
result = cursor.execute(sql)
print result.fetchall()

If I run it on pyodbc on Windows everything works just fine. Pyodbc seems to
just pass along the unicode string and MSSQL can deal with it fine.

If I run it on my Mac OSX 10.5.6 with the following chain of pyodbc ->
FreeTDS -> MSSQL, I get the following results:

Traceback (most recent call last):
File "odbctest.py", line 5, in <module>
result = cursor.execute(sql)
pyodbc.ProgrammingError: ('42000', "[42000] [FreeTDS][SQL Server]Could not
find stored procedure 'AUTO_INCREMEN'. (2812) (SQLExecDirectW)")

It is clearly not understanding the unicode string. FreeTDS seems to want
byte codes. If I send it as UTF-8 (or remove the unicode string) then all
works fine.

Is there any way for me to get the above to work without the conversion to
byte codes? Such as a way to turn off any sort of conversion on the FreeTDS
side.

I have a log file if that would help as well.

--
Michael Trier
http://blog.michaeltrier.com/




Archive powered by MHonArc 2.6.24.

Top of Page