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 286 Apr-18-2024, 09:55 PM
Last Post: deanhystad
  python script is hanging while calling a procedure in database prasanthi417 4 521 Jan-17-2024, 02:33 PM
Last Post: deanhystad
  Mysql and mysql.connector error lostintime 2 683 Oct-03-2023, 10:25 PM
Last Post: lostintime
  python call stored procedure mg24 2 1,089 Oct-18-2022, 02:19 AM
Last Post: mg24
  python call stored procedure with two parameter mg24 4 1,522 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,827 May-06-2022, 03:21 PM
Last Post: bowlofred
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,096 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  Defining an object's argument whose name is stored in a variable arbiel 2 2,191 Dec-11-2020, 10:19 PM
Last Post: arbiel
  capture print statement written in Stored Procedure in SQL Server brijeshkumar_77 0 2,564 Feb-18-2020, 03:22 AM
Last Post: brijeshkumar_77
  Execute SQL Server Stored Procedure brijeshkumar_77 0 3,042 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