AnsweredAssumed Answered

Arcpy editor transaction rollback

Question asked by vteyesriaustralia-com-au-esridist Employee on Feb 13, 2020
Latest reply on Feb 20, 2020 by mboyceesriaustralia-com-au-esridist

Hi,

 

I have a feature class without version and archiving.  When I attempt the code below, it threw a workspace already in transaction mode error. I tested with all combination of 

  • edit.startEditing(True/False,True/False)
  • With and without startOperation

nothing works. the only thing however that did worked is using arcpy.InsertCursor instead of arcpy.da.InsertCursor

def main():
    try:
        edit = arcpy.da.Editor(workspace)
        edit.startEditing(False, False)
        edit.startOperation()
        point = arcpy.Point(111,-60)
        pointGeom = arcpy.PointGeometry(point,"4326")

        row = []
        row.append('test')
        row.append(pointGeom)

        cursor = arcpy.da.InsertCursor(config.FC, ['testfield', 'SHAPE@XY'])
        cursor.insertRow(row)

        edit.stopOperation()
        edit.stopEditing(True)
    except Exception as e:
        #error handling


 

 

The following also did not work

I would like to roll back if an error occurred during a truncate and append. I tested with DeleteFeature, neither worked.

 with arcpy.da.Editor(workspace) as edit:
     arcpy.TruncateTable_management(config.PropertyFC)
    #arcpy.DeleteFeatures_management(config.PropertyFC)
     arcpy.Append_management(config.PropertyGDB, config.PropertyFC,"TEST")

Can someone advise?

 

Thanks

Outcomes