AnsweredAssumed Answered

How to prevent database copy when publishing geoprocessing tool?

Question asked by don.morrison on Dec 16, 2019
Latest reply on Dec 16, 2019 by don.morrison

I have a very simple python tool that returns results of a query on our enterprise geodatabase. When I publish that tool to our ArcGIS Server (not federated), the enterprise geodatabase gets copied to a file geodatabase, which is not what I want. I've read through the help on this many times and still can't figure out what I'm doing wrong. When I dump out the database path I can see the published code is accessing the file geodatabase copy instead of the SQL Server. I checked Server Manager and the database is listed as a registered Data Store, although it is not obvious how the literal string in my code gets matched to the name of the registered data store ("ROW_Habitat").  

 

I'm running this with arcpy that got installed with ArcPro (currently at 2.4.2)  and Python 3.6.8 and Advanced license.

 

Here is the python tool:

class SummaryStatsA(object):
    def __init__(self):
        self.label = "Summary StatsA"
        self.description = ""
        self.canRunInBackground = False

 

    def getParameterInfo(self):
        num_acres = arcpy.Parameter(
            displayName="Acres",
            name="num_acres",
            datatype="GPDouble",
            parameterType="Derived",
            direction="Output")
        num_orgs = arcpy.Parameter(
            displayName="Organizations",
            name="num_orgs",
            datatype="GPLong",
            parameterType="Derived",
            direction="Output")
        return [num_acres, num_orgs]        
    def isLicensed(self):
        return True

    def updateParameters(self, parameters):
        return

    def updateMessages(self, parameters):
        return

    def execute(self, parameters, messages):
        db_table_path = r'C:\Users\dmorri28\Documents\ArcGIS\Projects\MyProject\CC-SQL2k16-ERC.sde\ROW_Habitat.sde.summary_stats_TEST'
        arcpy.AddMessage("DB Path: %s" % db_table_path)
        with arcpy.da.SearchCursor(db_table_path, ['num_acres', 'num_orgs'], None) as cursor:  
            num_acres, num_orgs = cursor.next()
            parameters[0].value =  num_acres
            parameters[1].value =  num_orgs
        return

 

 

Here is how I do the publish, which I run from the Spyder IDE:

  arcpy.CreateGPSDDraft(results,
                          sddraft_file,
                          service_name,
                          server_type='FROM_CONNECTION_FILE',
                          connection_file_path=AppInfo.ags_connect_connection_file,
                          copy_data_to_server=False,
                          folder_name=AppInfo.ags_service_folder,
                          summary=service_summary,
                          tags=service_tags,
                          executionType='Synchronous',
                          showMessages='Info',
                          minInstances=0,
                          maxInstances=2)
   
    arcpy.StageService_server(sddraft_file, sd_file)
    arcpy.UploadServiceDefinition_server(sd_file, AppInfo.ags_connect_connection_file)

Outcomes