<?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 Update Postgres Query with arcpy in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/update-postgres-query-with-arcpy/m-p/789343#M189</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have a number of layers that i'd like to update the source tables for in an ArcGIS pro Project. &lt;/P&gt;&lt;P&gt;The layer sources are postgres database connections.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been able to change the "dataset" value in the connectionProperties, but tthis doesn't not change the value of "query" in the properties as "dataset" seems to correspond to the alias rather than the query itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;import pprint&lt;BR /&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;p=arcpy.mp.ArcGISProject('current')&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;m = p.listMaps()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l = m[1].listLayers()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for layer in l: pprint(layer.connectionProperties)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;curr_conn_info = {'dataset': 'daniel.gis.%layer_a'}&lt;/P&gt;&lt;P&gt;new_conn_info = {'dataset': 'daniel.gis.%layer_a'}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l[1].updateConnectionProperties(curr_conn_info, new_conn_info)&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2020 18:29:27 GMT</pubDate>
    <dc:creator>HughKelley</dc:creator>
    <dc:date>2020-11-02T18:29:27Z</dc:date>
    <item>
      <title>Update Postgres Query with arcpy</title>
      <link>https://community.esri.com/t5/python-snippets-questions/update-postgres-query-with-arcpy/m-p/789343#M189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have a number of layers that i'd like to update the source tables for in an ArcGIS pro Project. &lt;/P&gt;&lt;P&gt;The layer sources are postgres database connections.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been able to change the "dataset" value in the connectionProperties, but tthis doesn't not change the value of "query" in the properties as "dataset" seems to correspond to the alias rather than the query itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;import pprint&lt;BR /&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;p=arcpy.mp.ArcGISProject('current')&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;m = p.listMaps()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l = m[1].listLayers()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for layer in l: pprint(layer.connectionProperties)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;curr_conn_info = {'dataset': 'daniel.gis.%layer_a'}&lt;/P&gt;&lt;P&gt;new_conn_info = {'dataset': 'daniel.gis.%layer_a'}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l[1].updateConnectionProperties(curr_conn_info, new_conn_info)&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 18:29:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/update-postgres-query-with-arcpy/m-p/789343#M189</guid>
      <dc:creator>HughKelley</dc:creator>
      <dc:date>2020-11-02T18:29:27Z</dc:date>
    </item>
  </channel>
</rss>

