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)
Solved! Go to Solution.
The default behavior for ArcGIS Server is to copy data to the server if a data source isn't registered with Server or if there is a problem with a registered data source, so I would focus on the registered data source.
A database connection file is made up of more than just a database name, it has authentication information, version information, etc.... When you say the data source you are using in Server Manager is registered, are you sure they are the same data source and not a different data source to the same SQL Server database?
The default behavior for ArcGIS Server is to copy data to the server if a data source isn't registered with Server or if there is a problem with a registered data source, so I would focus on the registered data source.
A database connection file is made up of more than just a database name, it has authentication information, version information, etc.... When you say the data source you are using in Server Manager is registered, are you sure they are the same data source and not a different data source to the same SQL Server database?
You nailed it! I created a new SDE and used that to create a new entry in Server Manager's list of registered data stored and now it works exactly as expected. My guess is that the one that was there used different authentication credentials - I don't see any way inspect it to verify this. This is quite a relief, now I can move on the the next problem Thanks a ton Joshua.