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
  How to capture the result set from a stored procedure? dee 5 241 May-25-2024, 01:03 AM
Last Post: deanhystad
  Help with writing monitored data to mysql upon change of one particular variable donottrackmymetadata 3 415 Apr-18-2024, 09:55 PM
Last Post: deanhystad
  python script is hanging while calling a procedure in database prasanthi417 4 648 Jan-17-2024, 02:33 PM
Last Post: deanhystad
  Mysql and mysql.connector error lostintime 2 779 Oct-03-2023, 10:25 PM
Last Post: lostintime
  python call stored procedure mg24 2 1,149 Oct-18-2022, 02:19 AM
Last Post: mg24
  python call stored procedure with two parameter mg24 4 1,699 Sep-27-2022, 05:02 AM
Last Post: deanhystad
Question How can I import a variable from another script without executing it ThomasFab 12 8,114 May-06-2022, 03:21 PM
Last Post: bowlofred
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,541 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  Defining an object's argument whose name is stored in a variable arbiel 2 2,249 Dec-11-2020, 10:19 PM
Last Post: arbiel
  capture print statement written in Stored Procedure in SQL Server brijeshkumar_77 0 2,622 Feb-18-2020, 03:22 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