ArcPy functionality using and detecting Query Layers is very limited.
@RonnieRichards this should be possible using Python CIM Access
Here is a code snippet that could be used to find if a layer is a query layer.
aprx = arcpy.mp.ArcGISProject('current') m = aprx.listMaps()[0] qlyr = m.listLayers('MyQueryLayer')[0] cim_qlyr = qlyr.getDefinition("V3") if type(cim_qlyr.featureTable.dataConnection).__name__ == 'CIMSqlQueryDataConnection': print('Ureka, its a query layer')
Next you could continue with modifying other CIM property, like the SQLQuery
l_cim.featureTable.dataConnection.sqlQuery = "select OBJECTID,Shape,STATE_NAME,STATE_FIPS,SUB_REGION,STATE_ABBR,POP1990,POP2000,POP90_SQMI from ARCPYMAPPING_01.APM_PRO_states WHERE SUB_REGION = 'Mtn'" qlyr.setDefinition(cim_qlyr)
Data connection info is also there. Does this work for you?
Jeff - Layout and arcpy.mp teams
Sign in to post, follow content, and more. New here? Register for free.