Hello
I have a long sp (without parameters), with cursors, loop and many calculation.
The outer cursor/loop is for years 2025-2030.
There are also some inner cursors/loops.
When I execute it from ssms - it runs perfect.
When I run it from python - it stops somewhere, inconsistently, usually it does not finish the first year (2025).
I cannot get any error message.
I use Python 3.11.8
I run using 2 libraries - same result.
Any idea what happens, what can cause the sp to stop, how can I get an error message, what to check?
Any help will be highly appreciated.
Regards
Ofra A
import arcpy
schema_conn = r"mydb.sde"
sdesql_conn = arcpy.ArcSDESQLExecute(schema_conn)
env.workspace = schema_conn
sql = '''EXEC myschema.my_SP''';
sde_return = sdesql_conn.execute(sql)
or
import pyodbc
con = pyodbc.connect(
"DRIVER=SQL Server Native Client 11.0;"
"UID=myusername;"
"PWD=mypass;"
"TrustServerCertificate=Yes;"
"Trusted_Connection=No;"
"SERVER=mydb\GIS;"
"DATABASE=GISdb"
)
cursor = con.cursor()
cursor.execute("{call [myschema].[my_SP]}")
cursor.close()
con.commit()