pymssql

Miki Tebeka miki.tebeka at gmail.com
Sat Sep 10 00:22:09 EDT 2016


> 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'])



More information about the Python-list mailing list