Python Forum
Executing a MySQL Stored Procedure with variable
Thread Rating:
  • 3 Vote(s) - 2.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Executing a MySQL Stored Procedure with variable
#1
Hi,

Newbie here just trying to get a simple insert SP that requires 1 parameter (called BrandandRetailer) with PyMySQL.

Cant quite get the syntax right and was hoping for some assistance. Followed https://dev.mysql.com/doc/connector-pyth...lproc.html but she is still not working. Lambda says

name 'sql' is not defined: NameError

    
with conn.cursor() as cursor:
        # Call Stored Procedure

        args = [(event['BrandandRetailer'],)]
        result_args = cursor.callproc('IH_SP_AddBrandAndRetailer', args)
        cursor.execute(sql,)

        # connection is not autocommit by default. So you must commit to save
        # your changes.
    conn.commit()
Thanks in advance for any assistance.

Todd
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with writing monitored data to mysql upon change of one particular variable donottrackmymetadata 3 293 Apr-18-2024, 09:55 PM
Last Post: deanhystad
  python script is hanging while calling a procedure in database prasanthi417 4 522 Jan-17-2024, 02:33 PM
Last Post: deanhystad
  Mysql and mysql.connector error lostintime 2 687 Oct-03-2023, 10:25 PM
Last Post: lostintime
  python call stored procedure mg24 2 1,090 Oct-18-2022, 02:19 AM
Last Post: mg24
  python call stored procedure with two parameter mg24 4 1,532 Sep-27-2022, 05:02 AM
Last Post: deanhystad
Question How can I import a variable from another script without executing it ThomasFab 12 7,838 May-06-2022, 03:21 PM
Last Post: bowlofred
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,120 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  Defining an object's argument whose name is stored in a variable arbiel 2 2,194 Dec-11-2020, 10:19 PM
Last Post: arbiel
  capture print statement written in Stored Procedure in SQL Server brijeshkumar_77 0 2,565 Feb-18-2020, 03:22 AM
Last Post: brijeshkumar_77
  Execute SQL Server Stored Procedure brijeshkumar_77 0 3,051 Feb-18-2020, 02:59 AM
Last Post: brijeshkumar_77

Forum Jump:

User Panel Messages

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