Trying to run a MS SQL stored procedure that has an output parameter. I have followed documentation on how to do this, but when I run my code I get this error: SystemError: <class 'pyodbc.Error'> returned a result with an error set. Here is my code:
my_stored_procedure
CREATE PROCEDURE [dbo].[my_stored_procedure]
@IN1 INT
@IN2 INT
, @OUT INT OUTPUT
AS
BEGIN
SET @OUT = @IN + 1
END
myclass.py
z = sqlalchemy.sql.expression.outparam("ret_%d" % 0, type_=int)
x = 1
y = 2
exec = self.context.\
execute(text(f"EXEC my_stored_procedure :x, :y, :z OUTPUT"), {"x": x, "y": y, "z": z})
result = exec.fetchall()
context.py
def execute(self, statement, args=None):
if not args:
return self.session.execute(statement)
else:
return self.session.execute(statement, args)
Any suggestions or can anyone see what I am doing wrong?