May-09-2019, 07:04 AM
Hi,
I’m trying to extend on the assistance I have received here but with a slightly different scenario. This time I am using a select statement (not a stored procedure)
In addition, I want to take the easy path of just using column headers instead of having to type them all out
My attempt so far has been
Error I get is ‘list object has no attribute named column_names
Thanks in advance
Todd
I’m trying to extend on the assistance I have received here but with a slightly different scenario. This time I am using a select statement (not a stored procedure)
In addition, I want to take the easy path of just using column headers instead of having to type them all out
My attempt so far has been
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
cursor = cnx.cursor(dictionary = True ) query = ( "SELECT * FROM vw_myview order by vw_myview.ItemID" ) cursor.execute(query) rows = cursor.fetchall() json_rows = list .append( dict ( zip (rows.column_names, row))) cursor.close() cnx.close() return { 'statusCode' : 200 , 'headers' : { 'Access-Control-Allow-Origin' : '*' , 'Content-Type' : 'application/json' }, "body" : json.dumps(json_rows) } |
Thanks in advance
Todd