zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python调用存储过程

Python存储 过程 调用
2023-09-27 14:20:53 时间

 

def call_sp_test():
    delete_sql = "call sp_test()"
    # 打开数据库连接
    db = pymysql.connect(host=insert_mysqlserver, user=insert_username, password=insert_password, port=3306,db=insert_dbname)
    # 使用 cursor() 方法创建一个游标对象 cursor
    cursor = db.cursor()
    try:
        cursor.execute(delete_sql)
        db.commit()
    except Exception as e:
        print(e)
    db.close()