When I tried to use arcpy.management.Delete(fc) to delete a feature class from a SDE database, it failed with error message " ERROR 000601: Cannot delete ..\SECore_Tools_Testing_sde.DBO.point_windmill. May be locked by another application. Failed to execute (Delete)."
Then I add the following code before delete the feature class:
edit = arcpy.da.Editor(arcpy.env.workspace)
edit.startEditing(False, True)
edit.startOperation()
arcpy.management.Delete(fc)
edit.stopOperation()
edit.stopEditing(True)
I got different error message " ERROR 000496: table is being edited. Failed to execute (Delete)."
Please help! Thanks.
Is it in a map?
Did you restart Pro?
Where are you running this? from inside using Pro's python or external?
I am running a python tool inside Pro.
what about the first 2 questions?
I start a Arc Pro and add a new map, add some feature classes from a SDE database, add my new toolbox in Catalog pan.
If one of the layers you are adding is one you are trying to delete, don't add it and see if you can delete it from the database.
If you are trying to just remove it from the map, then you should be using removeLayer from ...
LayerFile—ArcPy | Documentation
Thank you, Dan. I tried to start new pro and not add any feature class, then run my tool from the toolbox. It gives me the same errors.
It could be anything, including how you set up your parameters in the toolbox. A lot more information would be needed
My tool can delete feature class from a FileGeodatabase (*.gdb) but not SDE.
SDE just opens up a whole new set of issues
Good luck