Cannot return results from stored procedure using Python cursor

Have you tried picking one of the resultsets?

for result in cursor.stored_results():
    people = result.fetchall()

It could be that it’s allocating for multiple resultsets even though you only have one SELECT stmt. I know in PHP’s MySQLi stored procedures do this to allow for INOUT and OUT variable returns (which again, you have none of, but maybe it’s allocating anyways).

The complete code I’m using (which is working) is:

import mysql.connector

cnx = mysql.connector.connect(user="me",password='pw',host="localhost",database="mydb")
cnx._open_connection()
cursor = cnx.cursor()

cursor.callproc("getperson",[1])

for result in cursor.stored_results():
    people=result.fetchall()

for person in people:
    print person

cnx.close()

Leave a Comment