djhenderson / pypyodbc

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

Return character data as string rather than byte array #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is not a defect, but a suggestion for enhancement.

Currently database columns of char or varchar types come as byte arrays.
The same is true for metadata, like column names.
It would be much nicer and more intuitive if they were converted to string type.

For example, I have a simple program reading the table and displaying the 
output; it is strange to see values looking like b'abcd'.
It is also easy to make mistake when comparing values.
Generally, in my opinion, we should normally use strings in our programs, and 
byte arrays only when we really need them.

This is my opinion, I don't know how the whole Python community would feel 
about it. My main language is Java, so I am used to this uniformity. 

Original issue reported on code.google.com by lilyev...@gmail.com on 8 Jul 2013 at 5:14

GoogleCodeExporter commented 9 years ago
I actually verified that the feature I am suggesting is there in pyodbc, so it 
makes a lot of sense to fix it. 

Original comment by lilyev...@gmail.com on 8 Jul 2013 at 6:54

GoogleCodeExporter commented 9 years ago
Issue 13 has been merged into this issue.

Original comment by jiangwen...@gmail.com on 9 Jul 2013 at 3:12

GoogleCodeExporter commented 9 years ago
I think by setting to unicode_results to True when connecting will solve the 
problem. 

How do you connect to the mdb file, did you use access connnection string to 
connect, or did you use the win_connect_mdb shortcut method to connect?

if you used connect string, can you try adding "unicode_results=True":
like below:

conn = pypyodbc.connect(u'Driver={Microsoft Access Driver 
(*.mdb)};DBQ=\\YourMDBfilepath.mdb',unicode_results=True)

And see if it works?

Original comment by jiangwen...@gmail.com on 9 Jul 2013 at 5:21

GoogleCodeExporter commented 9 years ago
I have updated the source code in GitHub:

https://github.com/jiangwen365/pypyodbc/blob/master/pypyodbc.py

Can you try again and see if it works?

Original comment by jiangwen...@gmail.com on 9 Jul 2013 at 11:31

GoogleCodeExporter commented 9 years ago
fixed in version 1.1.5

Original comment by jiangwen...@gmail.com on 11 Jul 2013 at 12:03