ReshmaA
ReshmaA

Reputation: 95

run stored procedure in python using pymssql

while executing stored procedure using pymssql getting error:

_mssql.MSSQLDatabaseException: (8144, b'Procedure or function GET_USER_DETAILS has too many arguments specified. DB-Lib error message 8144, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n')

code snippet:

        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)

stored procedure GET_USER_DETAILS, accept only one parameter, thats user name.

Upvotes: 2

Views: 3427

Answers (1)

ReshmaA
ReshmaA

Reputation: 95

The below code is working.

        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)

Upvotes: 1

Related Questions