I have tried this code and it is producing an infinite loop that repeatedly prints "0 Records Selected". I know that the query is resulting in 0 records being selected. Why is the value returned from the GetCount_management function that reports as 0 considered be greater than or equal to 1?
import arcpy
import os
from time import strftime
updateFC = r"C:\Users\RFAIRHUR\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\Trans Connection to SQL Server.sde\GDB_TRANS.TRANS.TRANSPORTATION_MAINT\CENTERLINE"
print "Make Feature Layer: " + strftime("%Y-%m-%d %H:%M:%S")
arcpy.MakeFeatureLayer_management(updateFC, "CENTERLINE_Layer")
arcpy.SelectLayerByAttribute_management("CENTERLINE_Layer", "NEW_SELECTION", "OBJECTID = -1")
records = arcpy.GetCount_management("CENTERLINE_Layer")
while (records >= 1):
print str(arcpy.GetCount_management("CENTERLINE_Layer")) + " Records Selected: " + strftime("%Y-%m-%d %H:%M:%S")
arcpy.SelectLayerByAttribute_management("CENTERLINE_Layer", "NEW_SELECTION", "OBJECTID = -1")
records = arcpy.GetCount_management("CENTERLINE_Layer")
print "Finished All Records: " + strftime("%Y-%m-%d %H:%M:%S")
This alteration to the code works without producing an infinite loop.
import arcpy
import os
from time import strftime
records = 0
while (records >= 1):
print str(records) + " Records Selected: " + strftime("%Y-%m-%d %H:%M:%S")
## print str(arcpy.GetCount_management("CENTERLINE_Layer")) + " Records Selected: " + strftime("%Y-%m-%d %H:%M:%S")
## arcpy.SelectLayerByAttribute_management("CENTERLINE_Layer", "NEW_SELECTION", "OBJECTID = -1")
## records = arcpy.GetCount_management("CENTERLINE_Layer")
print "Finished All Records: " + strftime("%Y-%m-%d %H:%M:%S")