pymssql

sum abiut suabiut at gmail.com
Thu Sep 8 20:48:05 EDT 2016


Hi,
i have used pymssql to connet to windows database but i want to be able
iterate and  only print out some specific fields.

here is what i did

conn=pymssql.connect(server,username,password,database)
    cus=conn.cursor()
    cus.execute("SELECT * FROM glbud ")

    for row in cus:
           print(row)
this works perfect, but when i try to iterate through and only print out
specific fields i got the error NameError: name 'budget_code' is not defined


for row in cus:
           print(row.budget_code)


NameError: name 'budget_code' is not defined

the column name is budget_code, in mssql server 2008


any idea what i am doing wrong? please advise



More information about the Python-list mailing list