<?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: Using replaceDataSource with an SDE Feature Dataset\FeatureClass in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-replacedatasource-with-an-sde-feature/m-p/191407#M14708</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried using the find and replace data Source feature in ArcCatalog?&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/006m/006m0000006q000000.htm" title="http://resources.arcgis.com/en/help/main/10.1/006m/006m0000006q000000.htm"&gt;ArcGIS Help 10.1 - Setting data sources&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Apr 2015 22:44:20 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2015-04-28T22:44:20Z</dc:date>
    <item>
      <title>Using replaceDataSource with an SDE Feature Dataset\FeatureClass</title>
      <link>https://community.esri.com/t5/python-questions/using-replacedatasource-with-an-sde-feature/m-p/191406#M14707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to change the data source from an FGDB to an SDE feature class.&amp;nbsp; I can get this to work for an SDE feature class that is not within a feature dataset.&amp;nbsp; For the life of me, I cannot get this to work for a feature class within a feature dataset.&amp;nbsp; The script fails on line 15.&lt;/P&gt;&lt;P&gt;The error message:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ValueError: Layer: Unexpected error&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe I am not correctly&amp;nbsp; specifying the &lt;STRONG&gt;workspath_path&lt;/STRONG&gt; or &lt;STRONG&gt;dataset_name&lt;/STRONG&gt; correctly.&amp;nbsp; The destination dataSource =&lt;/P&gt;&lt;P&gt;Database Connections\sdetest.sde\PIPELINE.BAKKEN\PIPELINE.Pipe&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SDE Connection: Database Connections\sdetest.sde&lt;/P&gt;&lt;P&gt;Dataset: PIPELINE.BAKKEN&lt;/P&gt;&lt;P&gt;Feature Class: PIPELINE.Pipe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os
mxd = arcpy.mapping.MapDocument('CURRENT')
ListLayers = arcpy.mapping.ListLayers(mxd)
workspace_path = "Database Connections\sdetest.sde"
dataset_name = "PIPELINE.BAKKEN\PIPELINE.Pipe"
# dataset_name = "BAKKEN\PIPELINE.Pipe"
# dataset_name = "PIPELINE.BAKKEN.PIPELINE.Pipe"
# Source: Database Connections\sdetest.sde\PIPELINE.BAKKEN\PIPELINE.Pipe
for Layer in ListLayers:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if Layer.supports("DATASOURCE"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(Layer)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if desc.catalogPath == "&lt;A&gt;\\\\ftwnas01a\\ProjectsNew\\NatGasOps\\NGOData\\Assets\\Bakken.gdb\\Bakken\\Pipe&lt;/A&gt;":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer.replaceDataSource(workspace_path, "SDE_WORKSPACE", dataset_name)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:37:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-replacedatasource-with-an-sde-feature/m-p/191406#M14707</guid>
      <dc:creator>JonBarlett</dc:creator>
      <dc:date>2021-12-11T09:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using replaceDataSource with an SDE Feature Dataset\FeatureClass</title>
      <link>https://community.esri.com/t5/python-questions/using-replacedatasource-with-an-sde-feature/m-p/191407#M14708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried using the find and replace data Source feature in ArcCatalog?&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/006m/006m0000006q000000.htm" title="http://resources.arcgis.com/en/help/main/10.1/006m/006m0000006q000000.htm"&gt;ArcGIS Help 10.1 - Setting data sources&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 22:44:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-replacedatasource-with-an-sde-feature/m-p/191407#M14708</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-04-28T22:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using replaceDataSource with an SDE Feature Dataset\FeatureClass</title>
      <link>https://community.esri.com/t5/python-questions/using-replacedatasource-with-an-sde-feature/m-p/191408#M14709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If in 10.3 &lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/mapping/updatingandfixingdatasources.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/mapping/updatingandfixingdatasources.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Updating and fixing data sources—ArcPy | ArcGIS for Professionals&lt;/A&gt; &lt;/P&gt;&lt;P&gt;I'm working on updating data sources with arcpy myself right, not just FGDB/SDE, so I'm looking at all of it too.&amp;nbsp; Looks like they recommend updating/replacing the database connection file.&amp;nbsp; #4 on that help page&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;import arcpy
aprx = arcpy.mp.ArcGISProject(r'C:\Projects\YosemiteNP\Yosemite.aprx')
aprx.updateConnectionProperties(r'C:\Projects\YosemiteNP\Vector_Data\Yosemite.gdb',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r'C:\Projects\YosemiteNP\DBConnections\Server.sde')
aprx.save()
del aprx&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if that will work for you or not, but might be worth checking.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:37:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-replacedatasource-with-an-sde-feature/m-p/191408#M14709</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T09:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using replaceDataSource with an SDE Feature Dataset\FeatureClass</title>
      <link>https://community.esri.com/t5/python-questions/using-replacedatasource-with-an-sde-feature/m-p/191409#M14710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Blake.&amp;nbsp; I am really trying to automate this through scripting.&amp;nbsp; We are converting over 100 FGDB feature classes to SDE, which will affect well over 100 ArcMap projects.&amp;nbsp; If I can't figure this out, then yes, that will probably be how we update our mxds.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 12:48:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-replacedatasource-with-an-sde-feature/m-p/191409#M14710</guid>
      <dc:creator>JonBarlett</dc:creator>
      <dc:date>2015-04-29T12:48:21Z</dc:date>
    </item>
  </channel>
</rss>

