Select to view content in your preferred language

Setting up an edit session Via versioned SDE to a table, and using updateCursor

367
4
03-19-2024 02:48 PM
EdX1
by
New Contributor III

Hello, 

I am having some difficulties using an updateCursor. I am running this script via the python terminal within ArcPro. When I run the updateCrusor, it hangs for 30+ minutes then has an error, "error: cannot update table". Can someone please verify that I have set up the cursor and edit session correctly, and provide any insight into why it might not work. 

I have the following variables:

 

 

 

sTable_path = r" path... @SDE.sde\SDE.Serv_TEST_FILE" #full path to the table
SDE_Workspace_Path = r" path... @SDE.sde" #path to the SDE connection
sTab = r"SDE.Serv_TEST_FILE" #table name #name of the table I want to update

 

 




I then set up my edit session and attempt to do some updates, it gets stuck at the updateCursor. 

 

 

 

        edit = arcpy.da.Editor(SDE_Workspace_Path) #opening workspace path
        edit.startEditing(False, True) 
        edit.startOperation()
        try:

            print("Retiring old assessment(s)...") 


            with arcpy.da.UpdateCursor(sTable_path, ("RecordStatus", "Retired"), where_clause=sOldWhere) as oRows:

 

 

It doesn't seem to matter if I use sTable_path or sTab in the updateCursor, both cause it to hang. I've checked if the item is locked. 

arcpy.TestSchemaLock(sTable_path) returns True, so the item should be able to be edited. Is there anything else I should check if it is a table lock issue?
0 Kudos
4 Replies
RhettZufelt
MVP Notable Contributor

Does adding in the Fields list as a List of fields make a difference (replace parrens with backets)?

with arcpy.da.UpdateCursor(sTable_path, ["RecordStatus", "Retired"], where_clause=sOldWhere) as oRows:

R_

0 Kudos
EdX1
by
New Contributor III

This does not make any difference, still stuck processing for a long period of time, eventually erroring out with message 'error updating table' after ~1 hour

0 Kudos
RhettZufelt
MVP Notable Contributor

The edit session is started the same way I do successfully on versioned data "Moving edits to base'.

Is it erroring out trying to establish the cursor, or trying to stop/save the edit session?

With the code supplied, not sure what else to check except maybe your where_clause.  Have you printed it, or tried it in a makefeaturelayer to ensure it is filtering as suspected?

Have you tried with a FGDB copy of the dataset?  Might help figure out if it is something with the edit session, locks, corrupt data, etc.

R_

0 Kudos
EdX1
by
New Contributor III

The error is occurring exactly at the updateCursor, it wont even reach a print statement on the next line. 

Good idea with trying with a local FGDB copy, I'll give that a go! And if that works, we can determine that there is likely an issue with permissions? 

0 Kudos