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
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