Bobspadger / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Feature Request: Row results as Dict's? #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I can greatly appreciate being able to access a column's value in a row this 
way:

{{{print row.the_column}}}

However, in some cases its extremely useful to access the column's via a Dict 
like this:

{{{print row["the_column"]}}}

One basic example on how this is helpful:

{{{SELECT column1+column2 AS "My Data" FROM mytable}}}

In this case, your resulting column name is "My Data". Obvious you cannot 
access that column via object oriented methods like this:

{{{print row.My Data}}}

Is this something you would consider adding to pyodbc? Great module btw!

Original issue reported on code.google.com by jake.e.w...@gmail.com on 22 Jun 2010 at 4:04

GoogleCodeExporter commented 9 years ago
I understand the issue, but you can use this workaround in the meantime:

  getattr(row, 'My Data')

You can also use row[0], of course, which is often handy.

Is this good enough?

Original comment by mkleehammer on 20 Aug 2010 at 7:51

GoogleCodeExporter commented 9 years ago

Original comment by mkleehammer on 5 Sep 2010 at 6:19