Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling sql server stored procedure using python pymssql

I am using pymssql for executing ms sql stored procedure from python. When I try to execute a stored procedure it seems not getting executed. The code gets completed without any error but upon verifying I can see the procedure was not really executed. What baffles me is that usual queries like select and similar ones are working. What might be missing here? I have tried the below two ways. The stored procedure does not have any parameters or arguments.

cursor.execute("""exec procedurename""")

and

cursor.callproc('procedurename',())

EDIT: The procedure loads a table with some latest data. When I execute the proc from local, it loads the table with latest data but I can see the latest data is not being loaded when done from python using pymssql.

like image 415
Ludwig Avatar asked May 11 '26 06:05

Ludwig


1 Answers

Thanks to AlwaysLearning to provide the crucial clue for fixing the issue, I have added connection.commit() after the procedure call and it started working!

like image 87
Ludwig Avatar answered May 12 '26 19:05

Ludwig