Python Forum
How to return value from a stored procedure of a MySQL database?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to return value from a stored procedure of a MySQL database?

I am working with a MySQL database and am having trouble with the line(s) of code that returns values when using a stored procedure that will return a single value.

When using a select statement, the following works perfect
data = cursor.fetchall()

return {'statusCode': 200,
        'Content-Type': 'application/json'},
        "body": json.dumps(data)}
the following example works fine for my sp but i’ve never had to return a value from the sp
cursor.callproc('sp_h', args)


return {
    "statusCode": 200,
    "headers": {
        "Content-Type": "application/json"
    "body": json.dumps({
        "message": "Combination(s) Successfully inserted"
What would I need to add to send back the single value into the body??

Thanks in advance


Possibly Related Threads…
Thread Author Replies Views Last Post
  mySQL Database error not resolving. cybertooth 2 453 Aug-30-2021, 05:45 PM
Last Post: ibreeden
  SaltStack: MySQL returner save less data into Database table columns xtc14 2 627 Jul-02-2021, 02:19 PM
Last Post: xtc14
  Problem updating value in MySQL database dangermaus33 1 622 Nov-24-2020, 08:32 PM
Last Post: dangermaus33
  chatterbot utf-8 errors with mysql database isolatedastronaut 0 643 Nov-08-2020, 06:54 AM
Last Post: isolatedastronaut
  capture print statement written in Stored Procedure in SQL Server brijeshkumar_77 0 1,255 Feb-18-2020, 03:22 AM
Last Post: brijeshkumar_77
  Execute SQL Server Stored Procedure brijeshkumar_77 0 1,527 Feb-18-2020, 02:59 AM
Last Post: brijeshkumar_77
  MYSQL how to assign a table for each user in my username table database? YoshikageKira 1 1,520 Dec-26-2019, 05:57 AM
Last Post: buran
  What do you think of this procedure to create a path to a folder atlass218 10 3,397 Sep-06-2019, 07:53 AM
Last Post: atlass218
  Custom Function to Return Database Values rm78 0 930 Sep-05-2019, 01:01 PM
Last Post: rm78
  Add a stored procedure with variable using MySQL Connector UtiliseIT 0 1,380 May-04-2019, 12:46 PM
Last Post: UtiliseIT

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020