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
Below is some code that should do the basics of this.
import arcpy
yxCoordString = arcpy.GetParameterAsText(0)
yStr,xStr = yxCoordString.split(",")
xFloat = float(xStr)
yFloat = float(yStr)
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
newExtent = df.extent
newExtent.XMin, newExtent.YMin = xFloat - 0.5, yFloat - 0.5
newExtent.XMax, newExtent.YMax = xFloat + 0.5, yFloat + 0.5
df.extent = newExtent
arcpy.RefreshActiveView()
You just need to Add Script it into a toolbox and then assign a parameter like below:
I have it zooming to a 1 x 1 degree extent by subtracting/adding 0.5 to the entered coordinates but you can set that to whatever you like.
This code takes no account of the coordinates entered being different to the coordinate system of the data frame.
Best Answer
You want to use the Append_Management tool.
If you know the attribute tables will match up (including data type), use
schema_type
NO_TEST
anyway (even though the documentation would suggestTEST
). If the attribute tables do not match up you will have to deal with field mappings, which can be a huge pain in arcpy. (If you are usingNO_TEST
and a subtype, make sure that you pass inNone
for thefield_mapping
argument.)