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

Return character data as string rather than byte array #19

Open
GoogleCodeExporter opened this issue Mar 15, 2015 · 5 comments
Open

Return character data as string rather than byte array #19

GoogleCodeExporter opened this issue Mar 15, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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
Copy link
Author

Issue 13 has been merged into this issue.

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

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

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

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

fixed in version 1.1.5

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

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant