Issue in running SQL Server Stored Proc using pyodbc
Asked Answered
D

0

0

I am trying to run an Stored Proc in SQL Server (Synapse) using pyodbc.This SP merely performs INSERT operation into a table.

sql =""" EXEC my_sp (?,?,?)"""
values = (str(v1),str(v2),int(v3))
cur.execute(sql,(values))
conn.commit()

This above code is not giving any error. But when I am querying the Table, I don't see the records. However, when I am running above SP in SSMS console, this works fine.

Can't figure out why this is so?

Any clue?

Donalt answered 29/11, 2022 at 14:41 Comment(2)
For diagnostic purposes, try using conn = pyodbc.connect( … , autocommit=True) and commenting out the conn.commit()Izak
I'm facing same issue. No data is being inserted to db, event after autocommit=True. However, output variable is being returned or if there is any select query. it seems only one statement is being executed.Responsible

© 2022 - 2024 — McMap. All rights reserved.