ok did some changes: conn=pymssql.connect(server,username,password,database) cus=conn.cursor( cus.execute("SELECT budget_code,budget_description,rate_type FROM glbud") for row in cus: print(row)
the above code display the selected column but when i iterate and try to print the fields, its not displaying anything and its not giving any error. conn=pymssql.connect(server,username,password,database) cus=conn.cursor( cus.execute("SELECT budget_code,budget_description,rate_type FROM glbud") for row in cus: print(row.budget_code,row.budget_description,row.rate_type) the above code it doesn't print out anything and it doesn't give me any error. any assistance will be very much appreciated. On Fri, Sep 9, 2016 at 1:38 PM, Lawrence D’Oliveiro <lawrenced...@gmail.com> wrote: > On Friday, September 9, 2016 at 12:48:50 PM UTC+12, sum abiut wrote: > > cus.execute("SELECT * FROM glbud ") > > Never use “select *”, except for testing. > > > 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 > > Possibly because you are getting back a tuple? Are you expecting some > other object type? > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list