<?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: Can you update query layer connection properties with Python like you can update SDE connection properties? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13197#M1051</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After looking into this a little more, I stand corrected. You might be able to change the data source&amp;nbsp; for the query layer using the arcpy.mapping.layer. You should be able to use findandreplaceWorkspacepath. I havent tried this, but it should be possible given the webhelp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The webhelp for arcpy.mapping is below:&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000008000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000008000000"&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Apr 2015 18:11:39 GMT</pubDate>
    <dc:creator>SamuelTompsett</dc:creator>
    <dc:date>2015-04-09T18:11:39Z</dc:date>
    <item>
      <title>Can you update query layer connection properties with Python like you can update SDE connection properties?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13195#M1049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been using SDE connections for many years and everytime the Oracle Database gets upgraded I need to programmatically change all the SDE connections in the mxds using python scritping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My organization is now moving towards query layers and I would like know if the same type of update can be done with the query layer connections using python scripting.&amp;nbsp; If this does exist, where would I find sample code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Apr 2015 20:19:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13195#M1049</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2015-04-08T20:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Can you update query layer connection properties with Python like you can update SDE connection properties?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13196#M1050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Samuel:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I at least use python to get the current query layer's properties that I would use to create a replica of the current query layer that would have updated database connection properties (e.g. a newer version of Oracle)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 18:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13196#M1050</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2015-04-09T18:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Can you update query layer connection properties with Python like you can update SDE connection properties?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13197#M1051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After looking into this a little more, I stand corrected. You might be able to change the data source&amp;nbsp; for the query layer using the arcpy.mapping.layer. You should be able to use findandreplaceWorkspacepath. I havent tried this, but it should be possible given the webhelp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The webhelp for arcpy.mapping is below:&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000008000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000008000000"&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 18:11:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13197#M1051</guid>
      <dc:creator>SamuelTompsett</dc:creator>
      <dc:date>2015-04-09T18:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can you update query layer connection properties with Python like you can update SDE connection properties?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13198#M1052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible to do this using arcpy.mapping.Layer():&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

mxd = arcpy.mapping.MapDocument(&amp;lt;mxdFile&amp;gt;)

lyr = arcpy.mapping.Layer(&amp;lt;queryLayer&amp;gt;)

oldConn = lyr.workspacePath
lyr.findAndReplaceWorkspacePath(&amp;lt;newSDEconn&amp;gt;, &amp;lt;oldSDEconn&amp;gt;)

mxd.save()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a note, you won't be able to use the replaceDataSource method for query layers because the dataSource property does not return the name of the tables used in the query layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;lyr = arcpy.mapping.Layer(&amp;lt;queryLayer&amp;gt;)&lt;/SPAN&gt;
&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;print lyr.dataSource&lt;/SPAN&gt;

&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;output = u'Database Connections\\ConnectionFile.sde\\SDE.%queryLayer'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:33:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13198#M1052</guid>
      <dc:creator>ChristianWells</dc:creator>
      <dc:date>2021-12-10T20:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can you update query layer connection properties with Python like you can update SDE connection properties?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13199#M1053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi do you have more info on this topic?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jun 2017 17:34:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-update-query-layer-connection-properties/m-p/13199#M1053</guid>
      <dc:creator>VivianMurga</dc:creator>
      <dc:date>2017-06-19T17:34:56Z</dc:date>
    </item>
  </channel>
</rss>

