[GIS] Delete SDE feature class features with ArcPy

arcgis-10.0arcpyenterprise-geodatabaseerror-000732features

I'm working on a script that will empty my SDE database of all data. How would I go about deleting features from feature classes using ArcPy?

I have an SDE connection created with a user that should have delete privileges. So far I've tried using the arcpy.DeleteFeatures_management from code and from the Delete Features toolbox in data management.

My DB has SDE feature datasets with SDE feature classes inside.

The Delete Features tool box errors out with:

ERROR 000732: Input Features: "Dataset Database Connections\Connection
to sde.sde\User.MyFeatureDataset\User.MyFeatureClass" does not exist
or is not supported.

The documentation is not really helping me. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000036000000

Best Answer

If you have delete rights, (and that isthe first thing you should check) and still the script does not run, then the problem is in the way that you are giving the path of the featureclass.

"Dataset Database Connections\Connection to sde.sde\User.MyFeatureDataset\User.MyFeatureClass" is a path that ArcCatlog & ArcMap undertsand, but not a standalone script.

What you need to do, is to give the complete path, including the location of the SDE connection. The SDE connection is usually in C:\Users\\AppData\Roaming\ESRI\Desktop10.0\ArcCatlog

You need to give the path of the featureclass as: "C:\Users\<User>\AppData\Roaming\ESRI\Desktop10.0\ArcCatlog\Connection to sde.sde\User.MyFeatureDataset\User.MyFeatureClass"

I have found that this path works when running stand alone scripts.

This question might explain the issue further: Define Workspace for SDE Connection in Python