python - 存储过程 - 游标状态无效
问题描述
我正在尝试运行存储过程,但我收到以下错误。我尝试做 AutoCommit = True 但仍然没有运气。
错误:
pypyodbc.ProgrammingError: ('24000', '[24000] [Microsoft][ODBC SQL Server Driver]Invalid cursor state')
代码
def sqlConnection():
conn = pypyodbc.connect('Driver={SQL Server};''Server=test;''Database=test;'
'Trusted_Connection=yes;autocommit=True')
cursor = conn.cursor()
return conn, cursor
def payments(cursor, conn):
cd = datetime.today()
formatted_date = datetime.strftime(cd, "%m/%d/%Y")
payments_q = """\
EXEC pRptMonTrTypeSumm @jobkey=?, @cdate=?
"""
params = (1, '08/30/2020')
fpl_payments_results = cursor.execute(payments_q, params)
for row in payments_results.fetchall():
payments3 = row[4]
print(payments3)
解决方案
SET NOCOUNT ON;
在存储过程之前尝试。
推荐阅读
- hazelcast - Hazelcast 集群成员可以存在于两个不同的组中吗?
- css - 使用源 URL(iOS 和 Android)在 Xamarin 表单中的 WebView 中包含 CSS
- powershell - 从 txt 文件中获取变量?
- javascript - 编辑表格不更新
- java - 编辑 EML 字符串
- python-3.x - 当数据的列是每个月的每一天时,如何绘制条形图?
- php - (Laravel)如何在模型中关联外键的外键
- reactjs - 如何从外部访问 localhost asp.net core web api
- excel - 如何使用分组填充多对多值(非 VBA)
- prolog - 如何在序言中使用递归算法连续打印图形路径