【问题标题】:run stored procedure in python using pymssql使用 pymssql 在 python 中运行存储过程
【发布时间】:2017-08-18 11:16:08
【问题描述】:

使用 pymssql 执行存储过程时出现错误:

_mssql.MSSQLDatabaseException: (8144, b'Procedure or function GET_USER_DETAILS has too many arguments specified. DB-Lib error 消息 8144,严重性 16:\n一般 SQL Server 错误:检查消息 从 SQL Server\n')

代码sn-p:

        connection = self.engine.raw_connection()
        cursor = connection.cursor()
        args= ('user')
        cursor.callproc("GET_USER_DETAILS", args)
        cursor.nextset()
        result = list(cursor.fetchone())
        cursor.close()
        connection.commit()
        print(result)

存储过程GET_USER_DETAILS,只接受一个参数,就是用户名。

【问题讨论】:

  • cursor.callproc("GET_USER_DETAILS", (args,))
  • 哇,成功了..@BurhanKhalid

标签: python stored-procedures


【解决方案1】:

下面的代码正在运行。

        connection = self.engine.raw_connection()
        cursor = connection.cursor()
        args= ('user')
        cursor.callproc("GET_USER_DETAILS", (args,))
        cursor.nextset()
        result = list(cursor.fetchone())
        cursor.close()
        connection.commit()
        print(result)

【讨论】:

    猜你喜欢
    • 2022-01-08
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 2016-02-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-25
    • 1970-01-01
    相关资源
    最近更新 更多