
pypyodbc - issue #6
Cannot access row object by column name, attribute error gets thrown
Accessing Row object by attribute fails. This works in pyodbc.
What steps will reproduce the problem? 1. Run a select query 2. Try accessing row object by column name 3. AttributeError will be thrown
E.g.
for row in cursor.fetchall(): id = row.id # <<<< fails
What is the expected output? What do you see instead? I expect the value of the column to be return, instead I get an attributeerror
What version of the product are you using? On what operating system? 0.9.3
Please provide any additional information below.
Comment #1
Posted on Feb 15, 2013 by Helpful Camel(No comment was entered for this change.)
Comment #2
Posted on Feb 25, 2013 by Helpful Camel(No comment was entered for this change.)
Comment #3
Posted on Mar 24, 2013 by Helpful CamelYou can change one line to enable it: In the method Cursor.init() from:
self.row_type_callable = row_type_callable or TupleRow
To: self.row_type_callable = row_type_callable or NamedTupleRow
After some consideration and testing, I tend to not enable that feature by default, which is not in DBI 2.0 standard, and also only ascii attribute will success:
for row in cursor.fetchall(): id = row.号码 # <<<< fails, field name must be ascii attributes
Status: WontFix
Labels:
Type-Defect
Priority-Low