使用Flask-MySQLdb调用MySQL存储过程 [英] Call a MySQL stored procedure with Flask-MySQLdb
问题描述
我在MySQL中创建了一个存储过程 spCreateUser
,我需要使用Flask-MySQLdb将两个参数传递给它。什么是正确的方式传递多个参数到存储过程?
我尝试使用执行
但我得到错误并非在字符串格式化过程中转换的所有参数
。
cur.execute 'spCreateUser',[_userEmail,_userPassword])
callproc
调用存储过程。
$ b $ pre $ code cur.callproc('spCreateUser',[_userEmail,_userPassword])
Flask-MySQLdb是MySQLdb的一个包装器,所以这可以在你使用该驱动器的任何地方工作。这不是特定于Flask扩展,甚至MySQLdb。任何符合PEP 249的软件包都会支持这个功能。
I've created a stored procedure spCreateUser
in MySQL and I need to pass two arguments to it using Flask-MySQLdb. What is the correct way to pass multiple arguments to a stored procedure?
I tried using execute
but I got the error not all arguments converted during string formatting
.
cur.execute('spCreateUser', [_userEmail, _userPassword])
Use callproc
to call stored procedures.
cur.callproc('spCreateUser', [_userEmail, _userPassword])
Flask-MySQLdb is a wrapper for MySQLdb, so this would work anywhere you were using that driver. It's not specific to the Flask extension, or even MySQLdb. Any package that conforms to PEP 249 would support this.
这篇关于使用Flask-MySQLdb调用MySQL存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!