<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Updating Data Source in ArcGIS PRO project with arcpy in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/1346996#M9256</link>
    <description>&lt;P&gt;I found that doing an SDE to SDE change worked for us only if we provide the full path to the new connection file to the connection_info['database'] property- trying to do the dictionary change method or just the 'find replace' name of the connection file bombs.&lt;/P&gt;&lt;P&gt;It would be nice if we could get a success/ fail result from the process instead of it just moving on giving a false positive that it worked. We could print the connection again, but that is ugly.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Nov 2023 02:14:24 GMT</pubDate>
    <dc:creator>StaticK</dc:creator>
    <dc:date>2023-11-08T02:14:24Z</dc:date>
    <item>
      <title>Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802811#M2121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Trying to update data source for layers in ArcGIS Pro maps programmatically. So, I must be misunderstanding the syntax for doing that explained &lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/mapping/updatingandfixingdatasources.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;. Because the following does not work:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

aprx &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcGISProject&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'path to my project file'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#This gets me list of all the maps&lt;/SPAN&gt;
maplist &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; aprx&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listMaps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#If I only want those belonging to MyGroup&lt;/SPAN&gt;
mygroup &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; aprx&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listMaps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'MyGroup'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#To get the layers in that group&lt;/SPAN&gt;
grouplayers &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; mygroup&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

new_sdeConn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'path to my SDE connection file'&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; grouplayers&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    old &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;connectionProperties	&lt;SPAN class="comment token"&gt;#also tried lyr.connectionProperties['connection_info']&lt;/SPAN&gt;
    lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateConnectionProperties&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;old&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; new_sdeConn&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This doesn't throw an error. it just doesn't do update the data sources as desired. The ESRI example goes like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;aprx&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateConnectionProperties&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'C:\Projects\YosemiteNP\Vector_Data\Yosemite.gdb'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                                r&lt;SPAN class="string token"&gt;'C:\Projects\YosemiteNP\DBConnections\Server.sde'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Does this maybe only work for the project as a whole?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:19:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802811#M2121</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2021-12-12T09:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802812#M2122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The issue you're having is that lyr.connectionProperties returns a dictionary but your new connection is a workspace path. You just need to access the right key in the dictionary:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;"&gt;in&lt;/SPAN&gt; grouplayers&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; old &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit; font-size: 14px;"&gt;=&lt;/SPAN&gt; lyr&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;"&gt;.&lt;/SPAN&gt;connectionProperties['connection_info']['database']
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;"&gt;.&lt;/SPAN&gt;updateConnectionProperties&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;"&gt;(&lt;/SPAN&gt;old&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;"&gt;,&lt;/SPAN&gt; new_sdeConn&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:19:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802812#M2122</guid>
      <dc:creator>StephenM</dc:creator>
      <dc:date>2021-12-12T09:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802813#M2123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stephen, thanks. Appreciate you chiming. I realize that connection_info is a dictionary. But I wasn't sure how to use it.&amp;nbsp;Keyword "database' only updates the database. I'm actually trying to switch this to use a different account (new 'user' and 'password') and was hoping to do so using a new SDE connection file. Can you maybe not to do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you look at the other keys in the dict, I need more than 'database' to be updated.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;{'authentication_mode': 'DBMS',
 'database': 'Prod',
 'dbclient': 'sqlserver',
 'db_connection_properties': 'myserver',
 'password': '&amp;lt;*********&amp;gt;',
 'instance': 'sde:sqlserver:myserver',
 'server': 'myserver',
 'user': 'myaccount',
 'version': 'dbo.DEFAULT'}&lt;/PRE&gt;&lt;P&gt;I am not an expert on these SDE connection files.&amp;nbsp;But&amp;nbsp;my understanding has always been that they store a reference to DB server/instance,&amp;nbsp; DB&amp;nbsp;name, authentication (and/pr password). So basically what's in the dictionary above. So merely updating 'database' in the dict wouldn't be sufficient, I think. To be safe, I tried it, and to no effect.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:19:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802813#M2123</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2021-12-12T09:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802814#M2124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, right. I forgot that you're using SDE connections. To switch&amp;nbsp;users I'd try modifying ['connection_info]['user'] and ['connection_info']['password'].&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; layers&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    old_conn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;connectionProperties
    new_conn &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; old_conn
    new_conn&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'connection_info'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'user'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; new_user
    new_conn&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'connection_info'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'password'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; new_pw
    lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateConnectionProperties&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;old_conn&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; new_conn&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:19:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802814#M2124</guid>
      <dc:creator>StephenM</dc:creator>
      <dc:date>2021-12-12T09:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802815#M2125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried passing in a complete new dict or just the 'user' and 'password' values as you suggested. I've tried the approach of referencing another layer's connectionProperties suggested &lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/mapping/updatingandfixingdatasources.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;lyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; m&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'some other layer'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
l&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateConnectionProperties&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;l&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;connectionProperties&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;connectionProperties&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;None of it is working. Darn!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:20:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802815#M2125</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2021-12-12T09:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802816#M2126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hm, maybe the credentials can't be modified in the way the other values can. I do notice that there aren't examples in the documentation that show&amp;nbsp;changing users in the connection properties. I had some success changing a connection from an OS authentication connection to&amp;nbsp;a DBMS connection, but I don't have multiple named DB users to test changing credentials.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Mar 2019 01:11:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802816#M2126</guid>
      <dc:creator>StephenM</dc:creator>
      <dc:date>2019-03-26T01:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802817#M2127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Has anyone solved this? I'm trying to move a workflow from Map to Pro, and this is hanging me up. It was so much easier with the lyr.replaceDataSource().&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 May 2019 15:08:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802817#M2127</guid>
      <dc:creator>BrettLessner_Nsight</dc:creator>
      <dc:date>2019-05-24T15:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802818#M2128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sadly I have given up banging my head against the desk trying to make this work.&amp;nbsp; I have searched through three other threads on GeoNet of people having a variation of this same problem without resolution:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/178455"&gt;updateConnectionProperties&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/233973"&gt;ArcPy Layer updateConnectionProperties not working as expected&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/233152"&gt;Replacing datasource does not work through arcpy&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and elsewhere:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://gis.stackexchange.com/questions/319216/repoint-enterprise-geodatabase-connection-using-arcpy-in-arcgis-pro" title="https://gis.stackexchange.com/questions/319216/repoint-enterprise-geodatabase-connection-using-arcpy-in-arcgis-pro"&gt;Repoint enterprise geodatabase connection using ArcPy in ArcGIS Pro - Geographic Information Systems Stack Exchange&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the end I found an old ArcMap .mxd with the same data also pointing to the wrong database, used good ole reliable lyr.replaceDataSource() to fix the data sources, imported the mxd as a new map in Pro, then copied the data over into my original map.&amp;nbsp; Sad but true.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2019 12:45:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802818#M2128</guid>
      <dc:creator>TobiSellekaerts</dc:creator>
      <dc:date>2019-07-02T12:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802819#M2129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As with so many other instances,&amp;nbsp;not finding any info on how to do it, I abandoned this a while back. But I'm sure I will have to look at&amp;nbsp;it again some day and will remember this post.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2019 22:00:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802819#M2129</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2019-07-03T22:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802820#M2130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tobi:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have not tried to recreate my update SDE datasource scripts from ArcMap to Pro yet so I have not experienced this hardship yet, but I have found that the Set Data Source(s)... functionality of ArcCatalog has not been ported over to Pro.&amp;nbsp; Although this ArcCatalog functionality does not work on batch mxds, I have found it very useful for moving publishing mxds from development to test to production where the SDE database is different for each environment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How many Pro aprxs are you looking to update the SDE connection properties for?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/message/798706-set-data-sources-tool-in-pro"&gt;Set Data Sources Tool in Pro&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2019 19:28:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802820#M2130</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2019-07-18T19:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802821#M2131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just one.&amp;nbsp; But within this one project there are 35 layers to be repathed.&amp;nbsp; I will exhaust many attempts at automation before changing them all manually!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2019 09:27:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802821#M2131</guid>
      <dc:creator>TobiSellekaerts</dc:creator>
      <dc:date>2019-08-01T09:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802822#M2132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everybody.&lt;/P&gt;&lt;P&gt;I run into this post and I realized that I may have something simple but useful.&lt;/P&gt;&lt;P&gt;The script below just goes layer by layer in a chosen map within the 'CURRENT' project and update user and password on sqlserver sde layers.&lt;/P&gt;&lt;P&gt;It is meant to be used within a script tool (pass the password as 'hidden string' data type). The logic excludes group and basemap layers and checks the data source in the connectionProperties looking for data source hints in the dictionary (I just look for SQL Server).&amp;nbsp;&amp;nbsp;The try/except block catches&amp;nbsp; NameError exception&amp;nbsp;for other layers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="comment token"&gt;# Input parameters are  the chosen map within the current project, new user name and password&lt;/SPAN&gt;
mapName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
newUser &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
newUserPass &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameter&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; 
&lt;SPAN class="comment token"&gt;#===================================&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#The default project is the current one....&lt;/SPAN&gt;
aprx &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcGISProject&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'CURRENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
currentMap &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; aprx&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listMaps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mapName&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#Loop layers excluding group layers and basemap&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; currentMap&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;isGroupLayer &lt;SPAN class="operator token"&gt;or&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;isBasemapLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#I have to exclude group layers and basemaps of course.....&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;try&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dataSource&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;','&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'='&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SQL Server'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# basically if the layer has a sql server data source&lt;/SPAN&gt;
                new_conn_prop &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;connectionProperties
                new_conn_prop&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'connection_info'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'user'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; newUser
                new_conn_prop&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'connection_info'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'password'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; newUserPass
                &lt;SPAN class="comment token"&gt;# Now i can update the connection properties dictionary of the layer&lt;/SPAN&gt;
                lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateConnectionProperties&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;connectionProperties&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;new_conn_prop&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
                arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;' has been updated !'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

        &lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt; NameError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;' does not have  a sql server data source'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alberto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:20:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802822#M2132</guid>
      <dc:creator>AlbertoAloe</dc:creator>
      <dc:date>2021-12-12T09:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802823#M2133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Folks, I was reminded of this thread when stumbling across a similar one - &lt;A _jive_internal="true" href="https://community.esri.com/thread/234739-update-sde-connection-properties-in-arcgis-pro-project-via-arcpy" target="_blank"&gt;here&lt;/A&gt;. Turns out that while I would've preferred to be able to update references from one SDE connection file (with embedded credentials) to another and do so programmatically, simply running an update on [user] and [password] was the quickest.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;conProp &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;connectionProperties

&lt;SPAN class="comment token"&gt;#depending on what all you're updating, you may have additional&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#keys you need to address&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#Examples: https://pro.arcgis.com/en/pro-app/arcpy/mapping/updatingandfixingdatasources.htm&lt;/SPAN&gt;

conProp&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'connection_info'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'user'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; newuser
conProp&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'connection_info'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'password'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; newpassword

layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateConnectionProperties&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;connectionProperties&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; conProp&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:20:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802823#M2133</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2021-12-12T09:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802824#M2134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've contemplated going the ArcMap route as well. Hopefully, I can avoid that, but...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Dec 2019 18:44:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802824#M2134</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-12-09T18:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802825#M2135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Starting at ArcGIS version 2.6, we improved this workflow so that you can use Enterprise Geodatabase Connection Files in the first parameter of the UpdateConnectionProperties function. You can now&amp;nbsp;do something like the following code sample.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy 
aprx &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcGISProject&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'C:\Projects\YosemiteNP\Yosemite.aprx'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
aprx&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateConnectionProperties&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'C:\Projects\YosemiteNP\DBConnections\TestGDB.sde'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                                r&lt;SPAN class="string token"&gt;'C:\Projects\YosemiteNP\DBConnections\ProductionGDB.sde'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also call updateConnectionProperties on the project, map, layer, table or LayerFile.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px; font-size: 14px;"&gt;More info and code samples can be found here:&amp;nbsp;&lt;A href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fpro.arcgis.com%2Fen%2Fpro-app%2Farcpy%2Fmapping%2Fupdatingandfixingdatasources.htm" style="color: #287433; border: 0px; font-weight: inherit; text-decoration: none; font-size: 14px; padding: 0px calc(12px + 0.35ex) 0px 0px;" target="_blank"&gt;Updating and fixing data sources—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:20:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802825#M2135</guid>
      <dc:creator>JeffMoulds</dc:creator>
      <dc:date>2021-12-12T09:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802826#M2136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;I used this script and nothing happened. I went into Catalog View to try and change the sde connection path and it won't save.&amp;nbsp;I can find and replace it, but when I hit apply, it would revert back to the old one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2020 22:43:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802826#M2136</guid>
      <dc:creator>BinhLe</dc:creator>
      <dc:date>2020-08-25T22:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802827#M2137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are 2 possibilities for why this isn't working:&lt;/P&gt;&lt;P&gt;1) I have not had luck with swapping sde connection files, and I&amp;nbsp;&lt;EM&gt;think&lt;/EM&gt; it is because in some situations, the data source may not recognize the input sde connection file path you have entered even if you entered a legitimate path. How data sources "think" about what their connection to sde really is is VERY COMPLICATED (usually, the path is on the c drive of your computer, for example...) and that's probably why ArcGIS Pro is moving to the "Connection Properties" dictionary to handle this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) The "updateConnectionProperties" method has a couple arguments that are not shown here. One is "validate" (true/false) and setting it to "false" got my code to work. Apparently, it wasn't seeing the output sde connection as valid, even though it was. It may be excessively finnicky. I think the argument right after the "to" sde connection file is whether or not to update joins, then this one, so:&lt;/P&gt;&lt;P&gt;updateConnectionProperties(Old Source, New Source, True &amp;lt;go ahead and update joins&amp;gt;, False&amp;lt;Don't require the output sde connection to be "valid"&amp;gt;) might work.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2020 14:20:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/802827#M2137</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-08-26T14:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/1000573#M5189</link>
      <description>&lt;P&gt;Afer a lot of trial and error, and help from this thread, I found this to work for me to change both the dataset (feature class) name and the workspace connection:&lt;/P&gt;&lt;P&gt;First, replace the dataset name with the new one and use False for the schema testing parameter. In most cases this will break the layer data connection, but this is only temporary.&lt;/P&gt;&lt;P&gt;lyr.updateConnectionProperties(lyr.connectionProperties,{'dataset':&amp;lt;datasetNameInDestinationWorkspace&amp;gt;},False,False)&lt;/P&gt;&lt;P&gt;The second step is to repoint to the new workspace. This time use the default value (True) for the schema testing parameter. The application will read the feature class properties, apply them to the layer, and consequently fixe the broken data source connection.&lt;/P&gt;&lt;P&gt;lyr.updateConnectionProperties(&amp;lt;currentWorkspacePath&amp;gt;,&amp;lt;newWorkspacePath&amp;gt;)&lt;/P&gt;&lt;P&gt;The workspace paths can point to file geodatabases or .sde connection files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 08:13:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/1000573#M5189</guid>
      <dc:creator>ClaudiuVarcalin</dc:creator>
      <dc:date>2020-11-12T08:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/1018651#M5461</link>
      <description>&lt;P&gt;So I run into the same problem. I needed to change layer that point to Oracle to point to sql server with a different name.&lt;/P&gt;&lt;P&gt;The main issue here is to turn a full path of feature class into a layer so you can get connection properties or just move symbology from one layer to anther.&lt;/P&gt;&lt;P&gt;Below os my code, two different way to turn FC into layer in pro arcpy.&lt;/P&gt;&lt;P&gt;It is ugly, I think we need a simple mathod just like replaceDataSource in ArcMap to do it.&lt;/P&gt;&lt;P&gt;My code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lyrFile = r"C:\temp\.ppp1.lyrx"
newFc = r"D:\temp\local express.sde\data2.DBO.PPP1_EXP_0"

connDic = {}

def main():
    #connDic = fc2layer1().connectionProperties
    connDic = fc2layer2().connectionProperties
    print("FC props=" + str(connDic))
    print("dataset= %s" % (connDic["dataset"]))
    print("connection info= %s" % (connDic["connection_info"]))
    # get layer to update
    origLyrF = arcpy.mp.LayerFile(lyrFile)
    origLyr = origLyrF.listLayers()[0]
    oldConnDic = origLyr.connectionProperties
    # update connection and dataset name
    oldConnDic["dataset"] = connDic["dataset"]
    oldConnDic["connection_info"] = connDic["connection_info"]
    origLyr.updateConnectionProperties(origLyr.connectionProperties,oldConnDic)
    # add to map
    aprx = arcpy.mp.ArcGISProject("CURRENT")
    aprxMap = aprx.listMaps("rel")[0]
    aprxMap.addLayer(origLyr)


def fc2layer1():
    # create a layer by adding to map
    aprx = arcpy.mp.ArcGISProject("CURRENT")
    aprxMap = aprx.listMaps("rel")[0]
    aprxMap.addDataFromPath(newFc) # must remove this layer later
    # search for layer in toc (added with alias name)
    desc = arcpy.Describe(newFc)
    lyr = aprxMap.listLayers(desc.aliasName)[0]
    return lyr


def fc2layer2():
    # create a lyr from lyrx file
    arcpy.MakeFeatureLayer_management(newFc,"lyr1")
    arcpy.SaveToLayerFile_management("lyr",r"C:\temp\xx.lyrx")
    lf = arcpy.mp.LayerFile(r"C:\temp\xx.lyrx")
    lyr = lf.listLayers()[0]
    return lyr

if __name__ == '__main__':
    main()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 13:11:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/1018651#M5461</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2021-01-21T13:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Data Source in ArcGIS PRO project with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/1024820#M5529</link>
      <description>&lt;P&gt;I can also confirm that this does not work in 2021.&lt;/P&gt;&lt;P&gt;I've implemented various variations of the solutions proposed on the posts related to this issue, and to conlcude things, none of them works.&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;Only way to do this is to go the ArcMap route. ConnectionProperties is just over-engineered and too complex to work with. Use lyr.findAndReplaceDataSource and you'll accomplish this in no time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 08:27:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-project-with/m-p/1024820#M5529</guid>
      <dc:creator>diaconori</dc:creator>
      <dc:date>2021-06-10T08:27:32Z</dc:date>
    </item>
  </channel>
</rss>

