ArcGIS Pro Set/Update Data source for all layers in a Map

2936
6
Jump to solution
09-17-2019 07:06 PM
Highlighted
New Contributor

I have to change the data source of all the layers of an ArcGIS Pro project map because of data migration from one sde to another sde. Is there any ArcGIS pro functionality to replace the data source of all the layers using one tool similar to ArcCatalog set data source functionality for .mxd?

1 Solution

Accepted Solutions
Highlighted
New Contributor

Kory KramerMichael Volz

I found a solution. One of the ESRI Tech Support article it has the solution. I have tested it and it replaced my data sources. Because of my projects has only one data source for each, it worked for me. Still we need to have the multiple data source replace capability for the situation. ESRI ArcGIS Pro development team should put this a bit of higher priority because it actually is a very important tool. below my code-

import arcpy as py

aprx = py.mp.ArcGISProject(r'project_location')

find_dict = {'connection_info': {'instance': 'sde:sqlserver:server_instance',
'server': 'server_name'}}
replace_dict = {'connection_info': {'instance': 'sde:sqlserver:server_instance',
'server': 'server_name', 'authentication_mode': 'OSA'}}
try:
aprx.updateConnectionProperties(find_dict, replace_dict)
py.AddMessage("Data Source Updated")
except NameError:
py.AddMessage(' does not replaced SQL data Source!!!')
aprx.save()

Hopefully this will help others.

View solution in original post

6 Replies
Highlighted
Esri Notable Contributor

That isn't in Pro yet.  See this issue which we have tagged as an ArcMap equivalency issue.

 

Reply
0 Kudos
Highlighted
Esteemed Contributor

This idea has been around for over 3 years now.  Do you know if a solution to this issue is even on the ESRI Road Map for Pro as an equivalency item that the Pro development will be working on?

Highlighted
New Contributor

Kory KramerMichael Volz

I found a solution. One of the ESRI Tech Support article it has the solution. I have tested it and it replaced my data sources. Because of my projects has only one data source for each, it worked for me. Still we need to have the multiple data source replace capability for the situation. ESRI ArcGIS Pro development team should put this a bit of higher priority because it actually is a very important tool. below my code-

import arcpy as py

aprx = py.mp.ArcGISProject(r'project_location')

find_dict = {'connection_info': {'instance': 'sde:sqlserver:server_instance',
'server': 'server_name'}}
replace_dict = {'connection_info': {'instance': 'sde:sqlserver:server_instance',
'server': 'server_name', 'authentication_mode': 'OSA'}}
try:
aprx.updateConnectionProperties(find_dict, replace_dict)
py.AddMessage("Data Source Updated")
except NameError:
py.AddMessage(' does not replaced SQL data Source!!!')
aprx.save()

Hopefully this will help others.

View solution in original post

Highlighted
New Contributor II

Hi I tried to replicate this and I could not update my connection property with a different version. I followed the technical guide. Are you able to update versions?

Highlighted
Esri Contributor

Hi Sean Phayakapong,

My reading of the documentation Updating and fixing data sources—ArcGIS Pro | Documentation 

tells me you should be able to update the version in the connection dictionary. But you would need to be sure the user accessing the Project (or the Server service account using the published .msd) has access to the version you are trying to use. It is possible that a new version is only accessible to the creator of the version.

Did you get this resolved?

Highlighted
Esri Contributor

More news - at Pro 2.6, a tool is provided to update simple parts of the data source path for all layers in a project.
But there is a bug https://my.esri.com/#/support/bugs/BUG-000134033  (maybe will be fixed at 2.7) that prevents this working for changes to enterprise geodatabase connections (using .sde files) unless the connections use the data owner or sde user - so not generally helpful when using OSA connections.

see this thread in the Ideas forum Need Ability to Replace Data Source for Multiple Layers for up to date info.