Update Postgres Query with arcpy

88
0
11-02-2020 10:29 AM
New Contributor

Hi, I have a number of layers that i'd like to update the source tables for in an ArcGIS pro Project.

The layer sources are postgres database connections.

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.

```

import pprint
import arcpy


p=arcpy.mp.ArcGISProject('current')


m = p.listMaps()

l = m[1].listLayers()

for layer in l: pprint(layer.connectionProperties)

curr_conn_info = {'dataset': 'daniel.gis.%layer_a'}

new_conn_info = {'dataset': 'daniel.gis.%layer_a'}

l[1].updateConnectionProperties(curr_conn_info, new_conn_info)

```

Reply
0 Kudos
0 Replies