Select to view content in your preferred language

What is best practice for editing features with arcpy in branch-versioned enterprise DB, getting error 160250

684
1
06-16-2023 11:08 AM
AaronManuel2
Regular Contributor

Hi, 

I'm working on some scripts to help with a database migration. Basically just a collection of "final load" scripts when we switch over, so we are not trying to load data individually for all of our features and tables.

The new databases are branch-versioned, we are switching from traditional versioning. Our existing on-prem DB is postgresql 9.6, we are moving to an aws DB, postgresql 12.11.

 

Trying to test with some simple appends is not working, I'm getting error 160250.

ERROR 160250: Objects in this class cannot be updated outside an edit session
Failed to execute (Append).

 

I tried using the editor class to see if that would work:

                        edit.startEditing(False,True)

                        edit.startOperation()

                        arcpy.management.DeleteRows(fpath)

                        arcpy.management.Append(prem_path,fpath,"NO_TEST" )

                        edit.stopOperation()

                        edit.stopEditing(True)
 
Same error. I then tried testing editing through a service since that is how branch versioning is supposed to work, but that doesn't work either. But maybe with the service there is a schema lock?
 
I'm guessing there is something about the branch versioning that is tripping things up here. My question is how am I supposed to do this with arcpy on a branch-versioned DB? Is this something I need to do on the Postgres side instead?
 
Thanks,
 
 

 

Tags (2)
0 Kudos
1 Reply
__JackCharde__
Regular Contributor

I don't know if you ever found an answer to this issue elsewhere, but If you want to use arcpy to edit branch versioned data directly from the EGDB, you need to be connected as the data owner (if you're not already). You should also reserve operations performed against branch versioned data directly through the SDE connection to bulk loading ops like what you're doing: truncate, append, etc.

For these bulk load ops, with versioned EGDB data, you need to specify multiuser_mode=True when instantiating the arcpy.da.Editor() class or the .startEditing() method for edits to work.

To perform other edits (and it's recommended all edits happen this way), you should use the ArcGIS API for Python. Specifically, through the VersionManager.

 

0 Kudos