| Issue 70: | problem with select | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
1. create a conection from ubuntu to MS SQL SERVER
2.
3.
What is the expected output? What do you see instead?i
I see IndentationError: expected an indented block
I would like to see the select result
What version of the product are you using? On what operating system?
Last pyodbc. Ubuntu 9.04
Please provide any additional information below.
>>> conn =
pyodbc.connect("DRIVER={FreeTDS};SERVER=defekas62;UID=emuser;PWD=temporal;DATABASE=em620")
cursor = conn.cursor()
>>> for row in cursor.execute("select USERNAME from JOBACTIONS"):
... print row.USERNAME
File "<stdin>", line 2
print row.USERNAME
^
IndentationError: expected an indented block
Why this error?
Many thanks and sorry for my english
Nov 21, 2010
(No comment was entered for this change.)
Status:
NoFix
|
This is actually a general Python issue, not pyodbc, but I can help. You must indent code that is "in" a for loop. First, try saving the code to a file instead of using the interactive batch session, at least while you get used to it. Second indent like this: conn = pyodbc.connect ("DRIVER=FreeTDS};SERVER=defekas62;UID=emuser;PWD=temporal;DATABASE=em620") cursor = conn.cursor() for row in cursor.execute("select USERNAME from JOBACTIONS"): print row.USERNAME Also, if your database is case-sensitive, you can use pyodbc.lowercase to force all returned column names to lower case. You would then use row.username instead of row.USERNAME.