How to Stop "SelectLayerByAttribute_management" creating temporary tables, while running script in ArcPro

466
3
Jump to solution
04-14-2024 11:08 PM
EdX1
by
Occasional Contributor

Hello, 

I am running a python script to update fields in a table based on polygons selected within ArcPro, via the python window in ArcPro.

At 3 parts in the script I use "SelectLayerByAttribute_management" to make selections from the table to get specific items from that table using a SQL query. 

Each time I call "
SelectLayerByAttribute_management" a temporary view is created within the contents panel which persist after the script is completed.

How can I avoid these from being created? I wish to avoid using arcpy.Delete_management("TEST_FILE_View1") to remove the tables because this adds an extra minute or two to the processing time which is not feasible given this task requires this process to be run many times over. What alternative options do I have?

Thanks. 

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

Providing representative code would be helpful because it is likely how you are calling the tool that is causing the issue.   From Select Layer By Attribute (Data Management)—ArcGIS Pro | Documentation

  • If the input is a feature class or dataset path, this tool will create and return a new layer with the result of the tool applied.

Are you passing a feature class or dataset path to the tool or the name of a layer or view?

 

View solution in original post

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

That tool doesn't support geoprocessing environment settings, but try

Project, Options, Geoprocessing ... Add outputs to an open map

Is it toggle on?, if so, try toggling it off.

'memory' workspace is another option to try

Write geoprocessing output to memory—ArcGIS Pro | Documentation

or at the end of your script, you can add another select layer by attribute with the clear selection option

Delete is generally the recommended approach, but it shouldn't take that long, unless you are working with non-locally stored data


... sort of retired...
JoshuaBixby
MVP Esteemed Contributor

Providing representative code would be helpful because it is likely how you are calling the tool that is causing the issue.   From Select Layer By Attribute (Data Management)—ArcGIS Pro | Documentation

  • If the input is a feature class or dataset path, this tool will create and return a new layer with the result of the tool applied.

Are you passing a feature class or dataset path to the tool or the name of a layer or view?

 

0 Kudos
EdX1
by
Occasional Contributor

This was the issue!
I was passing in a complete sde path to the table into my SelectLayerByAttribute instead of just passing it the table name of the table I wanted to use, which was open in my ArcPro project!!

Thank you very much. 

0 Kudos