I wonder if it is possible for a published Python tool in ArcGIS Server 10.6.1 (not Portal/Enterprise, just a stand-alone Server) to make use of a registered database connection. So, what I mean is, I have an instance of ArcGIS Server 10.6.1, and it has several registered database connections to an SDE on another machine.
I would like to publish a Python geoprocessing tool to that ArcGIS Server that can use these "pooled" SDE connections to read or write data, so I do not have to upload a separate SDE connection file for every GP tool every time I re-publish it or change the password. This would be similar to how Java web apps use a single Tomcat database connection, which is more efficient and easier to maintain.
But I can't figure out of this is possible or what the syntax would be. Here is a simple example of what I'd like to do in Python. All this script does is open up and list the datasets in an SDE schema:
import sys import os import arcpy scriptPath = sys.path arcpy.env.workspace = os.path.join(scriptPath, "read_only_connection.sde") ds = arcpy.ListDatasets() if len(ds) > 0: dataset_file = open(os.path.join(scriptPath, "datasets.txt"), "w") for d in ds: dataset_file.write(d + "\n") dataset_file.close()
If I copy up read_only_connection.sde to the script's directory after I publish, it will work. But read_only_connection.sde is already imported as a registered database on the server called read_only_connection (no .sde extension). How do I reference it from within Python? Is it even possible?