I can't delete a feature class from a SDE database in Pro

1760
5
06-12-2020 09:02 AM
YuLuo
by
New Contributor II

I am writing an ArcGIS Pro toolbox tool using Python. I am using arcpy.management.Delete(fc) to delete a feature class and it works on File Geodatabase (*.gdb). However it does not work for a SDE database. I open the Pro and add the feature classes from a SDE database and add my toolbox on Catalog pane. When I try to delete some feature classes, it fails with error message

" ERROR 000601: Cannot delete ..\SECore_Tools_Testing_sde.DBO.point_windmill.  May be locked by another application. Failed to execute (Delete)."

For investigating the functionality and access, I use Pro built-in geoprocessing tool "Delete" to delete some feature classes and it works successfully. I can see the deleted feature classes are gone from map even they were on the map.

Please help! Thanks!

0 Kudos
5 Replies
NobbirAhmed
Esri Regular Contributor

I'll investigate. Meanwhile, could you please share snippet of your code?

Thanks, Nobbir

GP Team.

0 Kudos
YuLuo
by
New Contributor II

Hello, Nobbir, here is my code:

def process_feature_classes(workspace, fc_list):

    arcpy.env.workspace = workspace
    try:

        featureclass_count = 0
        for i, fc in enumerate(fc_list):

            feature_count = int(arcpy.GetCount_management(fc).getOutput(0))

            if feature_count == 0:
                arcpy.Delete_management(fc)

    except:
        arcpy.AddError("Failed to process_feature_classes. {0}\n{1}".format(sys.exc_info()[0], sys.exc_info()[1]))

0 Kudos
YuLuo
by
New Contributor II

I also tried arcpy.management.Delete(fc) and got the same results.

0 Kudos
NobbirAhmed
Esri Regular Contributor

Hi Yu Luo, here are two topics that you can consult as to how to handle SDE data.

https://desktop.arcgis.com/en/arcmap/latest/manage-data/gdbs-in-sql-server/geodatabase-locks.htm

https://desktop.arcgis.com/en/arcmap/latest/manage-data/gdbs-in-sql-server/manage-geodatabase-locks....

When you handle SDE data you need to be aware of whether data is locked or not. Delete will fail if you don't have proper permission to manipulate the data. 

0 Kudos
YuLuo
by
New Contributor II

Hi, Nobbir, thank you for the help. The issue is due to the SDE process permission. After our SQL administrator assign a different server, the issue is resolved.