Loopback59 / pyodbc

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

Unable to call columns that consist of number characters #367

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have a table with a column named 2013.03.01
2. Fetch a row using a cursor
3. Try to manipulate data in the '2013.03.01' column in a for loop (for row in 
rows: )

What is the expected output? What do you see instead?

I would expect to get the data from the column, but I get syntax error:

   print(row.2013.03.01)
                 ^
SyntaxError: invalid syntax

 print(row.'2013.03.01')
                      ^
SyntaxError: invalid syntax

  When I try to assign the column name to a variable such as colname (colname = str('2014.04.01')) and call row.colname, I get a object row has no attribute colname error.  

for row in rows:
    colname = str("2013.03.01")
    print(row.colname)

AttributeError: 'pyodbc.Row' object has no attribute 'colname'

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

Python 2.7.6 | Anaconda 1.9.1 (64-bit)

pyodbc 3.0.7 

Please provide any additional information below.

I also tried escaping the '.' with \ but that did not change anything either.

Original issue reported on code.google.com by eravene...@gmail.com on 11 Apr 2014 at 8:55

GoogleCodeExporter commented 9 years ago
I should add that there are ways to get around this, in the same way that one 
would get around spaces in a column name or other oddities.  Certainly, it's 
not a high priority, and perhaps there is no priority at all due to the 
available workarounds.

Original comment by eravene...@gmail.com on 15 Apr 2014 at 3:18