I need to use arcpy to update (insert and edit) rows of a feature class in an SDE. I tried the following:
import arcpy
ed = arcpy.da.Editor("C:\\...\\my_sde.sde\\TEST_20230925.USER_20230925.TEST")
ed.startEditing(with_undo=False, multiuser_mode=True)
ed.startOperation()
cur = arcpy.da.InsertCursor("C:\\...\\my_sde.sde\\TEST_20230925.USER_20230925.TEST", '*',)
And I get the error:
Traceback (most recent call last):
File "<string>", line 2, in <module>
RuntimeError: cannot open workspace
The feature class is actually named "test", but the SDE is renaming it apparently. Using "test" instead has no effect on the result.
I followed this https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/120137... for this part, but I get the same error
ed.startEditing(with_undo=False, multiuser_mode=True)
I followed https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-... to set the workspace to my feature dataset, instead of the SDE, but I get "runtime error: cannot open workspace" like JaimeMcKeown. I'm not sure what MathewCoyle means by "Are you connected with a version user that can make edits?" Apparently JaimeMcKeown resolved that but without explaining how
If I right click on the feature dataset in the catalog pane and choose Privileges, the user "sde" has select, insert, and update privileges. But I'm not sure if arcpy would need to "sign in" to the "sde" user.
Making the feature class versioned has no effect other than not letting me manually add rows.
Please let me know if you have any ideas. Many thanks.