Select to view content in your preferred language

how to delete features from the topology layer with arcpy.da

1161
2
08-02-2017 10:23 AM
HalinaLewandowski
Emerging Contributor

I'm trying to delete all features from the SDE layer that has topology... the script fails on the arcpy.DeleteFeatures... 

ERROR:

arcgisscripting.ExecuteError: ERROR 999999: Error executing function.
A class in the topology necessitates validation being run within an edit session. [county.GIS_SDE.BldgInsp]
Failed to execute (DeleteFeatures).

Here is what I have:

SDE_bldginsp = county_con + os.sep + "county.GIS_SDE.bldginsp" 

areafield = "SHAPE.area"

 sde_concounty = sdeConnClass.SDE_Connection(gis_server, gis_dbcounty,'gis_sde','gis_sde')
county_con = sde_concounty.connection
gv.SDE_countyconnection = county_con

bldginspSDE_layer = "bldginsp_layer"


arcpy.MakeFeatureLayer_management(SDE_bldginsp, bldginspSDE_layer, "", "", "")
query = areafield + " > 0"
arcpy.SelectLayerByAttribute_management(bldginspSDE_layer, "NEW_SELECTION", query)

try:
   with arcpy.da.Editor(countyconnection) as edit:
     print " deleting old features."
     arcpy.SelectLayerByAttribute_management(bldginspSDE_layer, "NEW_SELECTION", query)
     arcpy.DeleteFeatures_management(bldginspSDE_layer)
     print "Deleted selected features from bldginsp "

     # APPEND local DORSalTx to SDE DORSalTx...
     fclist = [bldginsp_county_city_erased]
     arcpy.Append_management(fclist, bldginspSDE_layer)

     msg = "bldginsp updated sucessfully"
     print msg
     logging.info(msg)
     #print msg

except arcpy.ExecuteError:
print(arcpy.GetMessages(2))

Tags (1)
0 Kudos
2 Replies
by Anonymous User
Not applicable

I also ran into this. Were you able to ever find a solution?

0 Kudos
by Anonymous User
Not applicable

I'm running in to this now as well.  Were you ever able to resolve this?

0 Kudos