I am working with searchcursors for a .shp file with arcpy 3.0-py39. I am unable to get the searchcursor's sql clause to do frankly anything. Regardless of my clause I get the same result (all rows printed to screen, unordered).
For instance both of these provide the same response:
for row in arcpy.da.SearchCursor(in_table="Crashes_in_DC",
field_names="Tot_PedBik",
sql_clause=('TOP 3', None)):
print(f" {row[0]}" )
for row in arcpy.da.SearchCursor(in_table="Crashes_in_DC",
field_names="Tot_PedBik",
sql_clause=(None, 'ORDER BY Tot_PedBik DESC')):
print(f" {row[0]}" )
Solved! Go to Solution.
I don't think you can use either of those SQL queries against a shapefile (see Example 5a & 6): https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/searchcursor-class.htm
May have better luck using the where_clause with shapefiles.
I don't think you can use either of those SQL queries against a shapefile (see Example 5a & 6): https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/searchcursor-class.htm
May have better luck using the where_clause with shapefiles.
Ok I will try that.
They could at least throw a warning my way though...