Update data sources. enterprise server. dictionary. updateConnectionProperties

205
1
04-04-2024 06:21 AM
SGTomlins
New Contributor III

Greetings,

I have successfully updated connection properties in all scenarios EXCEPT enterprise to enterprise (dev to production).  The following code is my example.  I have 2.9 (yes i know outdated)  Python 1.9.1 ( again. outdated).

Is this a limitation of the updateConnectionProperties?

Is this related the attached screenshot, where the Update Data Sources is full of "Unsupported Items"

Feel like I am missing something obvious...  ?   help... 

import arcpy,pprint
# ## SGTomlins 3/27/24
# ## Examples of workspaces that can be used. Either a .gdb or a connection string.
# ## arcpy.env.workspace = r"C:\SGT\ESRI\ArcGIS_Pro\LoadLayerFiles\LoadLayerFiles.gdb"
# ## arcpy.env.workspace = r"C:\SGT\ESRI\_ConnectStrings\SDE@underdog-az@gis_prod_util_test.sde"
#

# ## find_dict = r'C:\SGT\SDE@underdog-az@gis_prod_util_test.sde.gdb'
# ## replace_dict = r'C:\Data\!Database_Connections\GISReader@underdog-az@gis_prod_util.sde'

find_dict = {'connection_info': {'user': 'sde',
'password': 'guessmenow!',
'version': 'sde.DEFAULT',
'server': 'underdog-az',
'instance': 'sde:sqlserver:underdog-az',
'dbclient': 'sqlserver',
'database' : 'gis_prod_util',
'db_connection_properties' : 'underdog-az'
}}

replace_dict ={'connection_info': {'user': 'sde',
'password': 'guessmelater',
'version': 'sde.DEFAULT',
'server': 'tinkerbell-az',
'instance': 'sde:sqlserver:tinkerbell-az\TINKER2019',
'dbclient': 'sqlserver',
'database' : 'gis_prod_util',
'db_connection_properties' : 'tinkerbell-az'
}}



# ## sets some variables and the output path for the created .lyrx files
aprfilenew = r'c:\SGT\TINKER2019-ResourceNoUtil31.aprx'

# ## Set your ArcGIS Project to excute the code on.
aprfilein = r'c:\SGT\TINKER2019-Resource_NoUtil.aprx'
p = arcpy.mp.ArcGISProject(aprfilein)

# ## Create lists for "Maps" and "Layers" in the .aprx
cnt=1
aprx = arcpy.mp.ArcGISProject(aprfilein)
for m in aprx.listMaps():
for lyr in m.listLayers():
print (lyr)
lyr.updateConnectionProperties(find_dict, replace_dict)

# ## Return the values of variable to the screen
print("working on it")

# ## Save a copy of the .aprx used in the code above.
p.saveACopy(aprfilenew)

print (".")
print ("..")
0 Kudos
1 Reply
SGTomlins
New Contributor III

Just grasping at straws..  this did not work either....


find_dict = {'connection_info': {'authentication_mode': 'DBMS',
'database': 'gis_prod_util',
'db_connection_properties': 'underdog-az',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:underdog-az',
'password': 'blahblahblah!',
'server': 'underdog-az',
'user': 'sde',
'version': 'sde.DEFAULT'},
'dataset': lyr ,
'workspace_factory': 'FeatureService'}

# } #,
# 'workspace_factory': 'SDE'}}

replace_dict = {'connection_info': {'authentication_mode': 'DBMS',
'database': 'gis_prod_util',
'db_connection_properties': 'tinkerbell-az',
'dbclient': 'sqlserver',
'instance': 'sde:sqlserver:tinkerbell-az\TINKER2019',
'password': 'noropeheredude!',
'server': 'tinkerbell-az',
'user': 'sde',
'version': 'sde.DEFAULT'},
'dataset': lyr,
'workspace_factory': 'FeatureService'}

0 Kudos