Thanks for the response, that works. Well it did until our IT group decided to change somethings. Now the feature classes in the staging database are all prefixed. So an example is in staging MGISSP.GISONEAST.PERM_ABA_Roads and the same feature class in Prod is MGISP.GISONEAST.PERM_ABA_Roads. Notice the difference at the beginning, staging is MGISSP and prod is MGISP. As a result your solution doesnt work any longer. Any other ideas? Again thanks for the help!
So no responses on this? I'll assume i'm doing it correctly then?
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
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.