AnsweredAssumed Answered

Not Able to Pass Where Clause in SearchCursor in ArcPy

Question asked by behClevest on Oct 15, 2018
Latest reply on Oct 16, 2018 by curtvprice

Can you please take a look at this snippet and let me know why I am not able to properly pass the Where Clause ('"[NAME_1]" = Ohio') in SearchCursor?



import arcpy
from arcpy import env
def unique_values(table , field):
with arcpy.da.SearchCursor(table, [field], '"[NAME_1]" = Ohio') as cursor:
return sorted({row[0] for row in cursor})
uniques = unique_values(r'C:\arcgis\ArcTutor\AAA\src\USA.shp' , 'NAME_2')
for unique in uniques:
  print (unique)

I am getting this error on runtime

Traceback (most recent call last):
File "<module1>", line 8, in <module>
File "<module1>", line 7, in unique_values
File "<module1>", line 7, in <setcomp>
RuntimeError: Unspecified error


Same error on this format as well

with arcpy.da.SearchCursor(table, [field], '"NAME_1" = Ohio') as cursor: