I am publishing a geoprocessing service on ArcGIS Server v10.3.0 that updates data on an ArcSDE Enterprise Geodatabase.
I have the following at the beginning of my script:
arcpy.env.workspace = "Database Connections/TestDatabase@hq-gissql01.sde"
As discussed at Connecting Geoprocessing Service to ArcSDE?, when I publish the script as a geoprocessing service, that line gets changed to:
arcpy.env.workspace = arcpy.env.packageWorkspace
This is all well and good, but
arcpy.env.packageWorkspace is simply the
v101 folder for this geoprocessing task. It is not the actual .SDE connection file. I can confirm that the .SDE connection file does get moved to the
v101 folder, but
arcpy.env.packageWorkspace is simply a file path to the
v101 folder--not that file.
Because of this, when I call
arcpy.ListDatasets(), an empty list gets returned. From what I can tell this is because the workspace is set to a folder on the server's file system, and not an .SDE file.
How are .py files being re-written when they are published as geoprocessing services? What is the proper syntax to use when setting the workspace so that the published version of the script references an .SDE file and not simply a file folder?