I've created a Python script to execute an SP using my cursor with connection odbc. I've tried everything I found but I can not execute the desired procedure. My code below:
import pyodbc
conn = pyodbc.connect( 'DRIVER={SQL Server};'
'SERVER=XXXXXX;'
'DATABASE=XXX;UID=XXXX;'
'PWD=XXX')
cursor = conn.cursor()
cmd_prod_executesp = 'EXECUTE DC_SAS_EvaluationUpdate'
cursor.execute(cmd_prod_executesp)
conn.close()
I have tried:
cmd_prod_executesp = '{call DC_SAS_EvaluationUpdate}'
cmd_prod_executesp = 'exec DC_SAS_EvaluationUpdate'
cmd_prod_executesp = '{CALL DC_SAS_EvaluationUpdate}'
I appreciate your help
thanks so much
Thanks so much everyone for your comments. Finally, in a quick comment from @GordThompson I applied the changes below and that worked.
import pyodbc
conn = pyodbc.connect( 'DRIVER={SQL Server};'
'SERVER=XXXX;'
'DATABASE=XX;UID=XXXX;'
'PWD=XXXX')
cursor = conn.cursor()
cmd_prod_executesp = """EXEC DC_SAS_EvaluationUpdate """
conn.autocommit = True
cursor.execute(cmd_prod_executesp)
conn.close()