With Arctoolbox and python scripting I’m creating long tool, but one of the steps is to select by attributes with SQL expression.
Let’s imagine that:
featureCar = arcpy.GetParameterAsText(0)
is Data Type/Feature Set: attributes weight
, length
, height
filter = arcpy.GetParameterAsText(1)
is Data Type/SQL Expression.
output = arcpy.GetParameterAsText(2)
In addition, when I run a tool from arctoolbox and previously specify in sql expression:
"weight" > 2000 AND "length" > 2 AND "height" > 1
from featureCar
with assistance of Query Builder
I’m expecting that this query as it is will be passed to arcpy.SelectbyAttribute_management
, but it seems not. How to pass this expression correctly to arcpy.SelectbyAttribute_management
in python script?
I’ve tried:
arcpy.SelectbyAttribute_management(featureCar, "NEW_SELECTION", "(filter)")
, and similar solutions with quoting filter
, but I always get ERROR 000358: Invalid expression.
I’ve noticed that is something with ''{}''.format(filter)
, but don’t know how.