mysql存储过程可以用new_调用mysql存储过程时发生sqlalchemy错误

我使用sqlalchemy在python的MySql服务器上运行查询。在

我用以下命令初始化sqlalchemy:engine = create_engine("mysql+mysqlconnector://{user}:{password}@{host}:{port}/{database}".format(**connection_params))

conn = engine.connect()

其中connection_params是包含服务器访问详细信息的dict。在

我正在运行这个查询:

^{pr2}$

使用conn.execute(query)(其中我将query设置为上面的字符串)。在

这个很好。在

我试图在我的like查询中放入:CREATE DEFINER=`root`@`localhost` PROCEDURE `test_anag`(IN str_identifier_code varchar(100))

BEGIN

SELECT

new_db.asset_specification.identifier_code,

new_db.asset_specification.asset_name,

new_db.asset_specification.asset_type,

new_db.asset_specification.currency_code,

new_db.sector_map.sector_description,

new_db.super_sector_map.super_sector_description,

new_db.country_map.country_description,

new_db.country_map.country_macro_area

FROM new_db.asset_specification

INNER JOIN new_db.identifier_code_legal_entity_map on new_db.asset_specification.identifier_code = new_db.identifier_code_legal_entity_map.identifier_code

INNER JOIN new_db.legal_entity_map on projecthf_db.identifier_code_legal_entity_map.legal_entity_code = new_db.legal_entity_map.legal_entity_code

INNER JOIN new_db.sector_map on new_db.legal_entity_map.legal_entity_sector = new_db.sector_map.sector_code

INNER JOIN new_db.super_sector_map on projecthf_db.legal_entity_map.legal_entity_super_sector = new_db.super_sector_map.super_sector_code

INNER JOIN new_db.country_map on new_db.legal_entity_map.legal_entity_country = new_db.country_map.country_code

WHERE new_db.asset_specification.identifier_code = str_identifier_code;

END

我可以使用CALL new_db.test_anag('000000')从mysql workbench的查询编辑器中运行存储过程,得到所需的结果(这是一行)。在

现在我试着跑:res = conn.execute("CALL new_db.test_anag('000000')")

但它失败了,以下例外情况除外sqlalchemy.exc.InterfaceError: (mysql.connector.errors.InterfaceError) Use multi=True when executing multiple statements [SQL: "CALL projecthf_db.test_anag('0237400')"]

我环顾四周,但我找不到任何对这个错误有用的东西,为了我的爱,我也不知道该怎么办。我不是Mysql和sqlalchemy(或任何RDBMS)方面的专家,但这个问题看起来应该很容易修复。如果需要更多信息,请告诉我。在

提前感谢你的帮助

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值