AnsweredAssumed Answered

Connecting to SDE Database in Geoprocessing Service?

Question asked by MollyKFoley on Mar 27, 2018
Latest reply on Mar 27, 2018 by MollyKFoley

I have an SDE database that is registered in the Data Store of my server:

 

I reference this database connection in the python script (the geoprocessing service) as this:

db_con = r'Database Connections\HbMonitoringTest_nbcidb_HabitatTestWriter.sde'

 

I check to see if the connection evaluates to true, but it doesn't and I'm not sure why. 

if arcpy.Exists(db_con):
    arcpy.AddMessage("your db connection worked")
else:
    arcpy.AddMessage("your db connection sucks")

 

Is this not the appropriate way to reference database connections in a geoprocessing service? Do I need to store the .sde connection file in a local folder on the server and connect using that instead? I have noticed int he v101 folder on the server, that the python script it contains did not replace "Database Connections" with the ESRI generated variable arcpy.env.packageWorkspace. Might that have something to do with it?

Outcomes