Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

Getting the output parameter after calling a stored procedure! (2 replies)

$
0
0
1. I did follow the example shown in the developer guide (page 45) as:

stored procedure:

CREATE PROCEDURE multiply(IN pFac1 INT, IN pFac2 INT, OUT pProd INT)
BEGIN
SET pProd := pFac1 * pFac2;
END

python code:

procedure_name = 'multiply'
arguments = (5, 5, 0)
cursor = mysql_connect.cursor()
cursor.callproc(procedure_name, arguments)
print(arguments)

and printing of the arguments list does not show me output parameter pPro. I got the same entry as:
(5, 5, 0)

How did you get the value ('5', '5', 25L)?

2. Same situation with a string as output parameter:

stored procedure:

CREATE PROCEDURE magazine.`string_concatenation`(IN pA varchar(50), IN pB varchar(50), OUT pC varchar(50))
BEGIN
SET pC = CONCAT(pA, pB);
END;

python code:

procedure_name = 'string_concatenation'
arguments = ('A', 'B', '')
cursor = mysql_connect.cursor()
cursor.callproc(procedure_name, arguments)
print(arguments)

This code will print: ('A', 'B', '')

How do I show the value of pC in python code?

Viewing all articles
Browse latest Browse all 384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>