AnsweredAssumed Answered

Python labeling sde connection properties for template mxd

Question asked by Mapper35 on May 4, 2016
Latest reply on May 4, 2016 by Mapper35

Hello

I am setting up some labeling in a template mxd that will be used by several people in my organization. The label info comes from related tables in an sde database so I am using a python labeling expression. In the expression I need to connect to sde in order to access the related table.  I have been successful getting this to work properly on my machine but when a coworker uses it, it fails because it is referencing the wrong connection.sde file.  I am using the code below thinking that it would pull the path to the sde connection file on the users machine, but it always returns the path of my connection.sde and not the users connection.

 

# Get database connection

mxd = arcpy.mapping.MapDocument("CURRENT")

layer = arcpy.Describe("Hydrants")

path = layer.dataElement.catalogPath

db_connection = os.path.split(path)[0]

 

Does anyone have any ideas on how to make the sde connection dynamic?

Outcomes