Python Forum
Execute SQL Server Stored Procedure
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Execute SQL Server Stored Procedure
#1
I need to execute a Stored procedure in SQL Server and capture all Print statements inside the SP. In addition to this, for other SP's i want to access the result set of the Stored Procedure. I have tried using few libraries like pyodbc, jaydebeapi etc. but none worked

db_conn = pyodbc.connect(connection_string)
sql = """\
DECLARE @RC int;
SET ANSI_WARNINGS OFF;
SET NOCOUNT ON;
{Call [dev_1].[sp_testing] (?, ?, ?)};
SELECT @RC AS rc;
"""
values = (parm1, parm2, parm3)
cursor = db_conn.cursor()
cursor.execute(query_string, value)
rows = cursor.fetchall()

Can anyone suggest how can achieve this. Is there any other library that i can use to achieve this. Appreciate your help with this. Thanks

It is now working.
I missed to put the commit
db_conn.commit()
it solved the issue.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python script is hanging while calling a procedure in database prasanthi417 4 504 Jan-17-2024, 02:33 PM
Last Post: deanhystad
  python call stored procedure mg24 2 1,072 Oct-18-2022, 02:19 AM
Last Post: mg24
  python call stored procedure with two parameter mg24 4 1,498 Sep-27-2022, 05:02 AM
Last Post: deanhystad
  How to take the tar backup files form remote server to local server sivareddy 0 1,895 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  capture print statement written in Stored Procedure in SQL Server brijeshkumar_77 0 2,556 Feb-18-2020, 03:22 AM
Last Post: brijeshkumar_77
  What do you think of this procedure to create a path to a folder atlass218 10 6,472 Sep-06-2019, 07:53 AM
Last Post: atlass218
  How to return value from a stored procedure of a MySQL database? UtiliseIT 0 2,328 Jul-22-2019, 10:14 AM
Last Post: UtiliseIT
  Add a stored procedure with variable using MySQL Connector UtiliseIT 0 2,293 May-04-2019, 12:46 PM
Last Post: UtiliseIT
  Unable to use sqlanydb to execute Sybase IQ Stored Procedure FORTITUDE 4 3,790 Sep-15-2018, 05:03 PM
Last Post: FORTITUDE
  execute a SQL stored proc within PYTHON PYTHONDUDE 3 9,480 Mar-21-2018, 04:15 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020