flahm

Update Cursor: deleting the cursor

Discussion created by flahm on Oct 24, 2011
Latest reply on Oct 25, 2011 by mzcoyle
Hi,
It appears that although I am using del cursor, my cursors are not really deleting, and are still locking the geodatabase.

#while loop
        intable = FC
        rows = arcpy.UpdateCursor(intable)
        row = rows.next()
        while row:
            date = str(row.getValue("BEGINDATE"))
            dateStr = str(date)
            print dateStr
            dateRep = dateStr.replace("-", "")
            print dateRep
            dateNew = dateRep[:8]
            print dateNew
            row.setValue("BEGINDATE_Temp", dateNew)
            rows.updateRow(row)
            row = rows.next()
        del row, rows

This is a temporary field, so after it is used for a calculation I try to delete the field
       try:
            arcpy.DeleteField_management(FC, ["BEGINDATE_Temp"])
        except:
            arcpy.AddMessage("Could not delete BEGINDATE_Temp field from " + FC)

I am continually getting the "Could not delete...." message.

When testing this in the python window in catalog, it appears that the cursors are not really being deleted by "del row, rows".  They are still locking the geodatabase and preventing me from deleting the fields.  Any idea what I am doing wrong or how one can truly remove cursor objects?

Thanks,
-f

Outcomes