1

I've loaded several layers from a PostgreSQL database with the PostGIS extension installed into an ArcGIS Pro 2.4 project.

I'd like to make the same map a few times for the data in several different identically structured schemas.

The layer data sources are defined using PostgreSQL queries.

for example I need to change SELECT * FROM california.scratch.d4_level_1_needs_pt into SELECT * FROM california.scratch.d5_level_1_needs_pt

or a slightly more complicated query:

SELECT 
    geom,linkid,route,finalscore,urgency,mobilityscore,
FROM 
    california.scratch.d4_level_1_needs_ln

It looks like I can update the layer source using:

import arcpy, pprint
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps()[0]
l = m.listLayers()[0]
pprint.pprint(l.connectionProperties)

and arcpy.mp.ArcGISProject().updateConnectionProperties()

but when I print the connectionProperties of one of the layers I don't see the query. it gives me:

{'connection_info': {'authentication_mode': 'DBMS',
                     'database': 'california',
                     'db_connection_properties': '***.***.**.**',
                     'dbclient': 'postgresql',
                     'instance': 'sde:postgresql:***.***.**.**',
                     'password': '<*********>',
                     'server': '***.***.**.**',
                     'user': 'user'},
 'dataset': 'california.scratch.%d4_partners_surveys_3',
 'workspace_factory': 'SDE'}

I could update the value for key dataset but that doesn't help me if I want to update the columns I'm pulling in via the query.

Additionally, is there any way to associate the connections I print in the python window with the layers in the list by Drawing Order?

I don't see any unique identifying info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.