1

I am using the cursor.callproc() to fetch the result from the database my stored procedure has two select statements between BEGIN and END. While running on MySQL I get the desired output.

I have my stored procedure as that fetches one column from each of the different table in the database

DELIMITER //
CREATE PROCEDURE fetchAuctionAndProduct()
BEGIN
    SELECT product_category_name from product_category;
    SELECT auction_id FROM auction;
END //
DELIMITER ;

Here are the result from the database that shows that two results are returned

result 1 result 2

Here is the flask api implementation where I have to call the stored procedure as soon as login is successful. I am getting the result only from the first select statement present in the stored procedure

@app.route('/login', methods =['GET', 'POST'])
def login():
    #print(request.form)
    mesage = ''
    if request.method == 'POST' and 'email' in request.form and 'password' in request.form:
        email = request.form['email']
        password = request.form['password']
        cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
        if('userlogin' in request.form):
            cursor.execute('SELECT * FROM user WHERE user_email = % s AND user_password = % s', (email, password, ))
            user = cursor.fetchone()
            if user and user['isVerified'] == 0:
                mesage = 'You are not verified by admin yet !'
            elif user:
                procursor = mysql.connection.cursor()
                procursor.callproc('fetchAuctionAndProduct')
                result = procursor.fetchall()
                print(result)
                mesage = 'Logged in successfully !'
                return render_template('user.html', mesage = mesage)
            else:
                mesage = 'Please enter correct email / password !'
    return render_template('login.html', mesage = mesage)

I have procedure call at

procursor = mysql.connection.cursor()
procursor.callproc('fetchAuctionAndProduct')
result = procursor.fetchall()
print(result)

I am unable to fetch both the select statement result in the application application output

Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46
  • The linked duplicate should answer your question. @ me if it doesn't. – snakecharmerb Dec 02 '22 at 22:03
  • @snakecharmerb I tried doing the same. It does not work – Bhupesh Patil Dec 02 '22 at 22:16
  • What connector package are you using (where does `mysql` in the question come from)? – snakecharmerb Dec 03 '22 at 11:56
  • I've retested the code in the 'Multiple result sets, no INOUT or OUT parameters defined' section of [my answer](https://stackoverflow.com/a/59546157/5320906), and it works for PyMySQL, MySQLClient and MySQL Connector. If it isn't working for you, please [edit] your question to show what you have tried, and the output. – snakecharmerb Dec 03 '22 at 12:39

0 Answers0