python - Django 多结果集

标签 python mysql django stored-procedures

我在我的 Django 应用程序中有一个使用 cursor.execute 调用的存储过程。存储过程返回 2 个结果集,但我似乎无法通过 Django 访问第二个结果集。访问多个结果集的正确方法是什么?

最佳答案

我最终做了这样的事情:

cursor = connections['prod'].cursor()
cursor.execute('''Your SQL''')
row = cursor.fetchone()

# do what you need to do with the first result set

cursor.nextset() #sets cursor to the next result set

# fetchone or fetchall and do whatever you want with the next result set

关于python - Django 多结果集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20382617/

相关文章:

在 map 中使用局部函数时出现 Python ValueError

Python正则表达式分隔以括号中的数字结尾的字符串

mysql - PHPMyAdmin 导入/导出同一服务器失败

mysql - 在 MVC3 和 MySQL 中使用 EF4.1 Code First 的问题

python - 如何使用 Django 查询多种数据库类型?

python - 未知标签类型 : continuous

python - ffmpeg和python的使用

php - 数组创建德语问题

mysql - Django MySQL 查询 Json 字段

django - 创建与 DetailView 相反的 View