Select to view content in your preferred language

Using Append in Python is suddenly requiring an edit session?

1563
11
02-11-2026 09:12 AM
Sean_Gambrel
Occasional Contributor

Hello,  A colleague and I have developed some python that, among other things, joins a table to a feature class and then copies specific features from there into a different, existing feature class.  This has run smoothly for over a year.  Suddenly the script is failing, stating that an edit session is needed to run the Append tool - which doesn't seem right - and anyway, our attempts at adding an edit session into the script causes the whole thing to fail from the get-go. 

A month or so ago there was a recent change to the database that the table comes from, but we've accommodated that change.  Nothing has changed on the gis-side in any way - feature classes, locations, etc.  Nothing has changed within our organizations enterprise / software that should affect this as far as I'm aware.  Any idea what's going on and how to repair this issue?   

I can't attach the full error message but the most pertinent part seems to be this:  "arcgisscripting.ExecuteError:  ERROR 160250: Objects in this class cannot be updated outside an edit session.  Failed to execute (Append)"

Here's what I think is the pertinent section of code, though it hasn't been changed:

...

survey_plat = r'V:\\gislu\\_DatabaseConnection\\editgis1.lu.user.dc.sde\\lu.LU.SURV_SurveyPlat'
count_pre_append = int(arcpy.management.GetCount(survey_plat)[0])

results = arcpy.management.Append(
inputs=surveys_added,
target=survey_plat,
schema_type='NO_TEST',
field_mapping="SURVEY_ID \"SURVEY_ID\" true true false 12 Text 0 0,First,#,V:\\prjlu\\SurveyPlats\\PlatProcessingAutomation\\SurveyProcessing.gdb\\SurveysAdded,survey_id,0,7999;SURVEY_TYP \"SURVEY_TYP\" true true false 25 Text 0 0,First,#,V:\\prjlu\\SurveyPlats\\PlatProcessingAutomation\\SurveyProcessing.gdb\\SurveysAdded,survey_type,0,7999;SURVEY_DES \"SURVEY_DES\" true true false 254 Text 0 0,First,#,V:\\prjlu\\SurveyPlats\\PlatProcessingAutomation\\SurveyProcessing.gdb\\SurveysAdded,survey_descr,0,7999;SURVEY_YR \"SURVEY_YR\" true true false 4 Long 0 0,First,#,V:\\prjlu\\SurveyPlats\\PlatProcessingAutomation\\SurveyProcessing.gdb\\SurveysAdded,survey_year,-1,-1;PLSS_COORD \"PLSS_COORD\" true true false 2 Text 0 0,First,#,V:\\prjlu\\SurveyPlats\\PlatProcessingAutomation\\SurveyProcessing.gdb\\SurveysAdded,PLSS_COORD,0,7999;LINK \"LINK\" true true false 256 Text 0 0,First,#,V:\\prjlu\\SurveyPlats\\PlatProcessingAutomation\\SurveyProcessing.gdb\\SurveysAdded,link,0,7999;PARCEL_NO \"PARCEL_NO\" true true false 12 Text 0 0,First,#,V:\\prjlu\\SurveyPlats\\PlatProcessingAutomation\\SurveyProcessing.gdb\\SurveysAdded,parcel_id,0,7999"
)
print(results)
print(arcpy.GetMessages())

count_post_append = int(arcpy.management.GetCount(survey_plat)[0])
count_delta = count_post_append - count_pre_append
print(f'{count_delta} records appended')

Tags (1)
0 Kudos
11 Replies
Sean_Gambrel
Occasional Contributor

Nothing so far.  But this is kind of a side project so we haven't been working on it non-stop. 

We tried the code you posted Wednesday and we got errors on the import line, assuming maybe something with the InsertCursor? and running it crashes straight out of the gate, predictably I suppose. 

We haven't tried your suggestions from Thursday, but hoping we can try again today.

Really appreciate your help and commitment here!!!

0 Kudos
HaydenWelch
MVP Regular Contributor

hmm, collections.abc is a newer thing in python. I added those imports for typing. You can also move those into the from typing ... import block if you're using Python < 3.13