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?

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
pythondumb
  • 1,187
  • 1
  • 15
  • 30
  • 1
    For diagnostic purposes, try using `conn = pyodbc.connect( … , autocommit=True)` and commenting out the `conn.commit()` – Gord Thompson Nov 29 '22 at 17:15
  • 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. – Milon Sarker Aug 10 '23 at 09:11

0 Answers0