MySQL程序没有输出,从python [duplicate]中获取所有结果

问题描述 投票:0回答:1

我有一个没有OUT或IN的过程,我无权更改该过程。

cursor = connection.cursor() 
cursor.callproc('store_procedure',())
res = cursor.fetchall()

我已经尝试了一切,但是无法从MySQL Procedure中获得结果。

没有Python的过程正在运行并返回结果,大约需要20秒,但返回了一些东西。

该过程返回多行。

我可以不更改程序就得到结果吗?

将MySQLdb软件包用于python。

python mysql mysql-python
1个回答
1
投票

Procedures有点复杂,因为它们可以返回多个结果集

 cursor.callproc('store_procedure')
 for result in cursor.stored_results():
    records = result.fetchall()
    print(records)

即使只检索一张表。

© www.soinside.com 2019 - 2024. All rights reserved.