存储过程:
delimiter |
create procedure get_product_info(in imid int(10),int iuser varchar(20))
begin
select * from tb_test where mid = imid and user = iuser;
end; |
delimiter ;
import mysql.connector
cnx = mysql.connector.connect( user='test',password='xxxx',host='192.168.10.194',database='test')
#cnx._open_connection()
cursor = cnx.cursor()
try:
args = (1,'op')
cursor.callproc("get_product_info", args)
#stored_results() 返回所有查询
#result 获取一次查询
for result in cursor.stored_results():
#rs返回一次查询结果
rs =result.fetchall()
except Exception as e:
print(e)