So no responses on this? I'll assume i'm doing it correctly then?
I would probably do something like this.import os
import sys
import traceback
import arcpy
sde_prod = r"Database Connections\GENERAL_DATA-PROD.sde"
sde_stage = r"Database Connections\STAGING-PROD.sde"
# I find this useful to add
if not arcpy.Exists(sde_prod) or not arcpy.Exists(sde_stage):
# Add contingency sde connection file on network
sde_prod = "somwhere1"
sde_stage = "somewhere2"
arcpy.env.workspace = sde_prod
fcList = arcpy.ListFeatureClasses("*PERM_ABA*")
try:
for fc in fcList:
arcpy.DeleteFeatures_management(fc)
print "Delete {0}".format(fc)
arcpy.Append_management(
os.path.join(sde_stage, fc), os.path.join(sde_prod, fc), "TEST")
print "Append {0}".format(fc)
except arcpy.ExecuteError:
# Get the tool error messages
msgs = arcpy.GetMessages(2)
# Return tool error messages for use with a script tool
arcpy.AddError(msgs)
# Print tool error messages for use in Python/PythonWin
print msgs
except:
# Get the traceback object
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# Concatenate information together concerning the error into a message
pymsg = "PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}".format(
tbinfo, sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n{0}\n".format(arcpy.GetMessages(2))
# Return python error messages for use in script tool or Python Window
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
# Print Python error messages for use in Python / Python Window
print "{0}\n".format(pymsg)
print msgs