I'm trying to finish a script that select a polygon attribute by location using the arcpy call. Here is my code:
project = arcpy.GetParameter(0)
proj_layer = r'memory/' + str('proj')
arcpy.MakeFeatureLayer_management(project_path, proj_layer)
arcpy.AddMessage("PROJECT_NAME = '{}'".format(project))
arcpy.SelectLayerByAttribute_management(proj_layer, "NEW_SELECTION", "PROJECT_NAME = '{}'".format(project))
The variable project_path is the correct path and I know it is because I used a print statement to verify that. I'm thinking that it may be some issue with the expression because the output is:
PROJECT_NAME = 'spokane_test'
Failed script UUIDScript...
Traceback (most recent call last):
File "C:\Users\jhodg1\Desktop\Construction Dev\UUIDScript2.py", line 58, in <module>
arcpy.SelectLayerByAttribute_management(proj_layer, "NEW_SELECTION", "PROJECT_NAME = '{}'".format(project))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 9727, in
SelectLayerByAttribute
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 9724, in
SelectLayerByAttribute
retval = convertArcObjectToPythonObject(gp.SelectLayerByAttribute_management(*gp_fixargs((in_layer_or_view, selection_type, where_clause, invert_where_clause), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 000358: Invalid expression
Failed to execute (SelectLayerByAttribute).
What happens is that the user is supposed to input the project name as a parameter and then I run the script which will then select the polygon based on its name. 'PROJECT_NAME' is the name of the field that I am querying in the 'project_path' layer and I know it exists and that I'm typing in the right name for the project name because I'm looking at the row so I know. Can anyone tell what I am doing wrong and what's making it print out "invalid expression"?
str('proj')?'proj'is already a string.project_path? Where is it defined?