Arcpy script runs on server but not as a geoprocessing service

476
2
02-23-2021 08:39 AM
Strahanjen
Occasional Contributor II

We have an insert script that runs fine on our server. When we publish it as a geoprocessing service, we get this error:

RuntimeError: cannot open '..\..\..\..\..\maptool\tools\spatialdb_spatialtest.sde\spatialtest.name.name_si' Failed to execute

In the script, the  connection looks like this:

fc = r"C:\apps\maptool\tools\spatialdb_spatialtest.sde\spatialtest.name.name_si"
cursor = arcpy.da.InsertCursor(fc, ("subject_item_id",  "address1", "address2", "city_name", "state_code", "zip_code"))

Any suggestions on how to troubleshoot and solve would much appreciated. I suspect the issue may be with the path?  I'm not sure why all of the ..\..\ are showing up in the error message.

 

0 Kudos
2 Replies
BlakeTerhune
MVP Regular Contributor

Is that database connection registered with the Data Store on Server?

Register your data with ArcGIS Server using Server Manager—ArcGIS Server | Documentation for ArcGIS ...

Strahanjen
Occasional Contributor II

Thanks for the tip. The database connection was not registered with the Data Stores on the Server. We registered the connection, republished the service and are still getting an error. We also made sure that the server user has permissions on the folder. I looked at the file that was created when we published the tool and found this:

# Esri start of added variables
g_ESRI_variable_1 = u'..\\..\\..\\..\\..\\maptool\\tools\\spatialdb_spatialtest.sde\\spatialtest.name.name_si'
# Esri end of added variables

 Any suggestions of what to try next? 

0 Kudos