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.
Thank you for your help!
However, when I run Pro built-in geoprocessing tool "Delete" with feature class I am trying to delete on the map, I can delete it successfully.
If it's part of the map I think you need to programmatically remove the layer from the map before you can delete it in your code. Otherwise, your map has a shared lock on it.
I start ArcPro without a template that shows blank Contents pane, no maps at all. Then I add my toolbox to the Catalog and run my tool. It gives me same error like the database "May be locked by another application". I think I have missed some code that should unlock SDE, but I don't know what is it.
The issue is due to the SDE process permission. After our SQL administrator assigned a different server, the issue is resolved. Thank you for the helps.
I am writing a python toolbox tool and run it in Pro.