I have the following stand alone script but it deletes all the features in the feature class instead what I have in the query. It also only prints out that there is 9 records that meet the query criteria witch is not correct there are more than 9 records. Seems pretty straight forward but I am Not sure what I am doing wrong.
I also tried using updatecursor but I get the same results, it deletes are the features in the feature class.
TaxPar = r"C:\Temp\TaxParcels1.shp"
# Process: Make Feature Layer
query = "DXF_TEXT LIKE 'Q%' or DXF_TEXT = ' ' or DXF_TEXT IS NULL"
arcpy.SelectLayerByAttribute_management(TaxPar, "NEW_SELECTION", query)
result = arcpy.GetCount_management(TaxPar).getOutput(0)
print ('{} has {} records'.format(TaxPar, result[0]))
if int(arcpy.GetCount_management(TaxPar).getOutput(0)) > 0:
arcpy.DeleteFeatures_management(TaxPar)
sql = "DXF_TEXT LIKE 'Q%' or DXF_TEXT = '' or DXF_TEXT IS NULL"
with arcpy.da.UpdateCursor(TaxPar, 'DXF_TEXT',sql) as cursor:
for row in cursor:
cursor.deleteRow()
else:
pass