AnsweredAssumed Answered


Question asked by agray1 on Jun 13, 2016

I am trying to update layer connection from one oracle geodatabase to another oracle geodatabase.  I also tried with the same geodatabase with different versions but none of it works.  I tried in the pro python window with the"current") and from my python ide (VS) which runs idle.   I would like to use this to change the version of some layers (change version does the whole aprx, not what I want) or the database dev, staging, uat, training, production.  What am I doing wrong?

  This is the code

import sys

import arcpy

#test project with a single map and a single layer

apr ="C:\xxx\ArcGIS\Project\testChangeConnection\testChangeConnection.aprx")


map = apr.listMaps()[0]

lay = map.listLayers()[0]


#development geodatabase 10.3.1 using an easy connect

devDb = r"C:\xxx\ArcGIS\Project\testChangeConnection\dev.sde"

#staging gdb is also 10.3.1 TNSNames connection because of TAF but also tried with easy connect to another db.

#featureclass with same name, type, schema, coordsys and data exists in both databases

stgDb = r"C:\xxx\ArcGIS\Project\testChangeConnection\stg.sde"


print(lay.connectionProperties) #prints connection to dev

apr.updateConnectionProperties(devDb ,stgDb, True, True)

print(lay.connectionProperties)  #prints connection to dev


lay.updateConnectionProperties(lay.connectionProperties ,stgDb, True, True)

#prints connection to dev

print(lay.connectionProperties) #prints connection to dev

del apr



I open the aprx and the source of the layer is indeed not changed.