I am wanting to create a definition query on a standalone table using arcpy. I have a way set up to do it on a layer file but because a table isn't a layer file this code obviously doesn't work.
The line of code that is bold is where things go wrong, because its not a layer. Is there a function similar to map_obj.listLayers for tables that I am missing?
# Access the map and the layer
map_obj = aprx.listMaps(map_name)[0]
layer_obj = map_obj.listLayers(layer_name)[0]
# Set a simple definition query
definition_query = f"{field_name} = '{query_value}'"
layer_obj.definitionQuery = definition_query
the Table class in the mapping module shows...
Table—ArcGIS Pro | Documentation
There are two ways tables can be referenced in a script for use in a project. To reference tables already in a project, use the listTables method on the Map class. To reference tables directly from a workspace, use the Table function.
definitionQuery
(Read and Write)
Provides the ability to get or set a tables's definition query. String