Thanks heaps for your comments, manage to get it work using the as_dict` parameter of the `cursor` object,
cus=conn.cursor(as_dict=True) 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']) cheers, On Sat, Sep 10, 2016 at 3:22 PM, Miki Tebeka <miki.teb...@gmail.com> wrote: > > for row in cus: > > print(row.budget_code) > > > > > > NameError: name 'budget_code' is not defined > You'll need to use a DictCursor to be able to access rows by name and not > position (which IMO is the preferred way). > > cus = conn.cursor(pymysql.cursors.DictCursor) > cus.execute("SELECT * FROM glbud ") > for row in cus: > print(row['budget_code']) > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list