pombreda / pypyodbc

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

Can't get column value in the row by column name in MS ACCESS 2010 #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Connect to MS access 2010 database
2. select all rows from table
3. try to retrieve column in row by name

What is the expected output? What do you see instead?
Get value of the expected column in row. I see "nothing" for all rows

What version of the product are you using? On what operating system?
Version 1.1.1

Please provide any additional information below.
for i in connection.cursor().execute(SQL).description:
  i[0] 

returns byte strings (b'id', b'name'). so b'id' != 'id'

Potential solution (works for me, but must be tested):

REPLACE
col_name = Cname.value
TO
col_name = Cname.value.decode("utf-8")

Original issue reported on code.google.com by Grigory....@gmail.com on 16 Apr 2013 at 3:30

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, please add "unicode_results=True":
like below:

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

if you used win_connect_mdb, then you will need to check the source code of 
win_connect_mdb defination in pypyodbc, if there's unicode_results = True in it.

Next version I will default has win_connect_mdb method set unicode_results to 
True to avoid that problem

Original comment by jiangwen...@gmail.com on 17 Apr 2013 at 2:02

GoogleCodeExporter commented 9 years ago

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