Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
1  
If you are not able to use the Delete Features in data management successfully it suggests to me that there is a permission problem. I would focus on getting the tool to work first then once that is the case you'll be abl to use Copy As Python Snippet from the Geoprocessing | Results window to get the Python code right. –  PolyGeo Apr 18 '12 at 22:38
    
I notice in the online help it says: "If you want to delete all features from an ArcSDE feature class, use this tool against the ArcSDE feature class (not a layer) without a selection in order to perform a database truncate rather than a row by row deletion of features to delete all the features. The database truncate operation is much faster when deleting all the features in a feature class." Have you tried using both the layer and the feature class? Also, have you tried deleting a feature class that is not in a feature dataset to see whether that works? –  PolyGeo Apr 18 '12 at 22:38
add comment

1 Answer 1

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

share|improve this answer
    
shrug I've found the "Database Connections" shortcut to always work even in standalone Python scripts. –  blah238 Apr 19 '12 at 6:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.