MySQL Forums
Forum List  »  Connector/Python

Can't Get Result Set as Dictionary
Posted by: Ron Mittelman
Date: August 22, 2017 11:26AM

So I'm using MySQL Connector/Python version 2.1.7 to execute a stored procedure. Result set is coming as list of tuples, which is expected. I need column names, so I'm using "dictionary=True" in the cursor declaration per the docs. However, still only returns list of tuples. Docs say it should work since version 2.0.0 of connector.

Here is code:

import mysql.connector
proc = 'audit_report'
parms = [data['schoolid'], dateToISO(data['startdatedefault'],'from'), dateToISO(data['enddatedefault'],'to'), joinIntList(data['studypgms'], joinWith), joinIntList(data['fedpgms'], joinWith), joinIntList(data['statuses'], joinWith), data['fullssndefault']]
conn = mysql.connector.connect(user='myUser', database='myDB', password='myPwd')
cursor = conn.cursor(dictionary=True)
cursor.callproc(proc, parms)

for result in cursor.stored_results():
print(result.fetchall())

So I get the list of tuples, not the list of dictionaries.
Any ideas why this won't work? Is it because I'm calling a store proc instead of executing sql code?

The stored procedure is complex, so there are multiple tables, and crosstabs. Result column names appear just fine when I execute the procedure in MySQL Workbench.

Thanks...

Options: ReplyQuote


Subject
Written By
Posted
Can't Get Result Set as Dictionary
August 22, 2017 11:26AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.