0

I have a Procedure that is not having OUT or IN, I don't have the permission to change the Procedure.

cursor = connection.cursor() 
cursor.callproc('store_procedure',())
res = cursor.fetchall()

I tried everything but I can't get the results from MySQL Procedure.

The procedure without Python is running and return the results, it takes about 20sec but is return something.

The Procedure returns multiple rows.

Can I get the results without change the Procedure?

Use MySQLdb package for python.

pioupiou
  • 836
  • 2
  • 14
  • 29

1 Answers1

1

Procedures are a bit more complicated, because they can return multiple resultsets

 cursor.callproc('store_procedure')
 for result in cursor.stored_results():
    records = result.fetchall()
    print(records)

Even when you retrieve only one table.

nbk
  • 45,398
  • 8
  • 30
  • 47
  • I forget to tell that i use MySQLdb and is not support the stored_results thanks :) – pioupiou Apr 29 '20 at 11:04
  • enable the mysql logs in mysql and see what mysql is getting and there should also be the numbers iof row returned, but in my experience when noithing comes out it is usually that the procedure doesn't have a answer. i testeteh code with **import mysql.connector** – nbk Apr 29 '20 at 11:16
  • besides in the official home page claims that python 3 isn't supported yet. try the connector – nbk Apr 29 '20 at 11:20
  • with connector is working great thanks :) cheers – pioupiou Apr 29 '20 at 11:31