AnsweredAssumed Answered

Problem settings arcpy.env.workspace to SDE connection in separate module on arcgis server

Question asked by DemersM on Sep 26, 2016
Latest reply on Nov 30, 2016 by mitchh300

I have problem defining arcpy.env.workspace in a separate module when publishing the script as a Geoprocessing Service on arcgis server.


For instance:


my main tool script:


from myModule import myTool


workspace = "Database Connections\\GEOP011@demma18.sde"

tableName = "DEMMA18.MyTable"

myTool.execute(workspace, tableName)




import arcpy


def execute(workspace, tableName)

    arcpy.env.workspace = workspace



def doSomething(tableName)

     with arcpy.da.SearchCursor(tableName, ["OBJECTID"]) as cursor:
            for row in cursor:




When published to the server, this script will return error : cannot open DEMMA18.MyTable


However, if I put the same code in a single .py file it runs on the server without error. Any Idea what is going wrong?