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

Cannot access row object by column name, attribute error gets thrown #6

Closed
GoogleCodeExporter opened this issue Mar 15, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

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.

Original issue reported on code.google.com by johnjian...@gmail.com on 13 Feb 2013 at 4:54

@GoogleCodeExporter
Copy link
Author

Original comment by jiangwen...@gmail.com on 15 Feb 2013 at 2:45

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Original comment by jiangwen...@gmail.com on 25 Feb 2013 at 2:30

  • Added labels: Priority-Low
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Author

You 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


Original comment by jiangwen...@gmail.com on 24 Mar 2013 at 11:42

  • Changed state: WontFix

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