Loprz / pypyodbc

Automatically exported from code.google.com/p/pypyodbc
0 stars 0 forks source link

Bad cursor description (mixed bytes and strings) on Ubuntu 14.04 #52

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Enter Python on terminal 
Python 3.4.0 (default, Apr 11 2014, 13:05:11)[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pypyodbc
>>> db=pypyodbc.connect('DSN=Veramtex')
>>> cur=db.cursor()
>>> res=cur.execute("select 1 as 'Num', 'a' as 'String'")
>>> print(res.description)
[(b'n', <class 'int'>, 20, 19, 19, 0, False), (b's', <class 'str'>, 1, 1, 1, 0, 
False)]

What is the expected output? What do you see instead?
Description should give the list of column names as strings, not only the first 
character in bytes.  If I perform the very same steps on a windows machine, the 
last line reads:
[('num', <class 'int'>, 20, 19, 19, 0, False), ('string', <class 'str'>, 1, 1, 
1, 0, False)]
which I consider correct.

What version of the product are you using? On what operating system?
Python 3.4
pypyodbc 1.3.3

Please provide any additional information below.

Original issue reported on code.google.com by marc.van...@gmail.com on 12 Sep 2014 at 1:18

GoogleCodeExporter commented 8 years ago
Try this patch. You can either apply the patch or go into the pypyodbc.py file 
and find the line:

    col_name = Cname.value

And change it to

    col_name = from_buffer_u(Cname)

Original comment by wwer...@lwsi.com on 20 Nov 2014 at 12:54

Attachments:

GoogleCodeExporter commented 8 years ago
It works!  Thanks.
Result:
[('num', <class 'int'>, 20, 19, 19, 0, False), ('string', <class 'str'>, 1, 1, 
1, 0, False)]

Original comment by marc.van...@gmail.com on 20 Nov 2014 at 4:28