Hi all,
I'm trying to replace some datasources and I ran into the following issue with enterprise databases.
My replacements are in a dictionary of {oldsource: new source}.
The data is accessed through an SDE file, at T:\...\SDENAME.sde
So the catalogPath should be T:\...\SDENAME.sde\gdb.owner.featureclass
However, the following is what arcpy.da.Describe["catalogPath"] returns:
C:\TMP\ArcGISProTemp13528\8850eb38373ef1ba0d601f80c13fcdef.sde\featureDataset\featureclass
My dictionary is
{T:\...\SDENAME.sde\gdb.owner.featureclass : T:\...\SDENAME2.sde\gdb.owner.featureclass2} so this doesn't work for me.
I recall from other posts that this is normal, but I can't remember how to actually get a usable path that I want?
I just ignore that temp path for the sde connection file. Use the workspace properties to inspect the connection, find the appropriate dictionary key by comparing connection properties (not file path), and then update the connection properties from there.
For example, my common use is updating the database instance from test to production. You would be looking up the connection properties from your dictionary connections rather than hard coding the value, but you would still update the connection properties similarly.
for layer in map.listLayers():
if layer.supports("connectionProperties"):
cp = layer.connectionProperties
for key, value in cp["connection_info"].items():
cp["connection_info"][key] = value.replace("testInstance", "prodInstance")
layer.updateConnectionProperties(layer.connectionProperties, cp)
Hmm. This might ask for a complete re-write of this part of my workflow. I've been using CIM to update, and having the actual path hard-coded has made the most sense so far since I'm also messing with file GDB and shapefile data.
The annoying thing is if you use the Python window in a different project and just list the catalogPath for the layer in the map, it'll give you the correct path that I'm looking for.
But using the python window in the project itself or my scripting tool gives me this dumb temp file.
So clearly this information can be found, but no clue how to make it work.
Anyway, thanks. I'll play around and see what I get.