google-code-export / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
1 stars 0 forks source link

pyodbc Not returning results with Python3.3 on Mac OS X #339

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install unixodbc
2. install FreeTDs
3. Install pyodbc

What is the expected output? What do you see instead?
Run select query - expect db results - 

get "pyodbc.ProgrammingError: No results.  Previous SQL was not a query."

What version of the product are you using? On what operating system?
Python 3.3.2 FreeTDS 0.9.1, pyodbc 3.0.7 Mac OS X 10.8.3

Please provide any additional information below.
I've been fighting this one for a while.  This is the code:

conn = 
pyodbc.connect('TDS_VERSION=7.2;charset=UTF-8;DRIVER=/usr/local/lib/libtdsodbc.s
o;DATABASE=test;SERVER=<SQL SERVER>;PORT=1433;UID=<UID>;PWD=<PASSWORD>')
csr = conn.cursor()
csr.execute(str("select id, value from test"))
rows = csr.fetchall()

The code works on Python 2.7 with pyodbc installed from the same source code as 
used in python 3.  I've also tried it in a Python3 virtualenv with pyodbc 
installed via pip.

Changing charset to UTF8, UTF16 or UTF-16 seems to have no effect.  Nor does 
changing TDS_VERSION to 8.0.

Original issue reported on code.google.com by nbed...@reddeer.gb.com on 19 Sep 2013 at 5:48

GoogleCodeExporter commented 9 years ago
An update on this.  It looks like a Unicode problem.  When running the code in 
the console (as opposed to Eclipse with PyDev) I get:  pyodbc.ProgrammingError: 
('42000', "[42000] [FreeTDS][SQL Server]Incorrect syntax near '�'. (102) 
(SQLExecDirectW)").  

Original comment by nbed...@reddeer.gb.com on 26 Sep 2013 at 4:34