Select to view content in your preferred language

Edit Session for Update Cursor?

2571
3
08-27-2018 07:44 AM
JoeBorgione
MVP Emeritus

ArcMap 10.5.1

In Problems with an Update Cursor I noted that I received an error upon running an update cursor on a table view.  I just ran it again and got:

Runtime error
Traceback (most recent call last):
File "<string>", line 10, in <module>
RuntimeError: The operation is not supported within an edit session.

    with arcpy.da.UpdateCursor('ba_view',fields)as updatecursor:
        for row in updatecursor:   # this is line 10 the error refers to....

I suspect my lack of experience with update cursors is the root cause; I ran it in an edit session in ArcMap to get the error.  I don't get the error outside of an edit session.

For some reason, I thought update cursors needed to be run in an edit session: is that not the case?

Joshua Bixby

That should just about do it....
0 Kudos
3 Replies
JoshuaBixby
MVP Esteemed Contributor

Are you starting the edit session with ArcPy?

0 Kudos
JoeBorgione
MVP Emeritus

No.  I open it in the ArcMap Session and run the update cursor code in the python window.

That should just about do it....
0 Kudos
DanPatterson_Retired
MVP Emeritus

UpdateCursor—Data Access module | ArcGIS Desktop 

perhaps you are overgeneralizing this note

Note:

Opening simultaneous insert or update operations on the same workspace using different cursors requires the start of an edit session.

0 Kudos