AnsweredAssumed Answered

updateConnectionProperties

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 arcpy.mp.ArcGISProject("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 = arcpy.mp.ArcGISProject(r"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)

apr.save()

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

apr.save

del apr

print("done")

 

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

Outcomes