我使用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)方面的专家,但这个问题看起来应该很容易修复。如果需要更多信息,请告诉我。在
提前感谢你的帮助