I am at a loss! After hours of searching and testing, in Arcmap (10.3) I simpy can't get beyond this error:
RuntimeError: Objects in this class cannot be updated outside an edit session [ContactsAndFaults]
while attempting to open an UpdateCursor. The feature class is in a personal database and I am able to add a field, but not use the following:
uid = fc + "Somestring" with arcpy.da.UpdateCursor("C:\\arcmaptest\\Paddock_Valley_Reservoir.mdb\\" + fc, ("OID@", uid)) as cursor: for row in cursor: row[1] = fc + "-" + anotherstring+ "-" + row[0] # basically append the OBJECTID to the uid string cursor.updateRow(row)
Any suggestions?
Solved! Go to Solution.
Hi
If your data is part of something like topology or network it cannot be update without edit session.
You can start edit in ArcMap and then try to run the script.
In general you should try to move from mdb to gdb.
Have fun
Hi
If your data is part of something like topology or network it cannot be update without edit session.
You can start edit in ArcMap and then try to run the script.
In general you should try to move from mdb to gdb.
Have fun
Or wrap your update cursor in something like this :
# open an editor session edit = arcpy.da.Editor(os.path.dirname(outputDiff)) # dirname of the fc is the db name edit.startEditing(False, False) # check these setting for your environment edit.startOperation() # do the update loop # stop editing edit.stopOperation() edit.stopEditing(True)
Yes,
Opening the edit session was required as some of the feature classes (tables) in the personal database are participating in topologies. Thanks for the suggestion!
I would recommend converting your personal geodatabase to a file geodatabase.