Issue 70: problem with select
Status:  NoFix
Owner: ----
Closed:  Sep 2009
Reported by davidtuti, Aug 27, 2009
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
Sep 5, 2009
Project Member #1 mkleehammer
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.

Status: Invalid
Nov 21, 2010
Project Member #2 mkleehammer
(No comment was entered for this change.)
Status: NoFix