Hello,
ArcGIS Pro 2.95. Oracle/SDE database and versioned.
The question is two parts. Thanks in advance.
1. In SDE versioned editing, do users have to save the username/password in the connection file before running the Python editing code?
1.1 At the same time, do users have to switch the version to the editing version (not in the default version) using the Geodatabase Connection property?
2. If the above is true, is there a way to change the connection file's version using Python/ArcPy. The layer in the map project is already switched to the editing version, so I can get the editing version from the connection property of the editing layer. Uses change versions frequently. I think ArcObject can do this.
3. code segments (indent does not work here):
workspace_sde=r"C:\Users\LiY\AppData\Roaming\ESRI\ArcGISPro\Favorites\SDEConnection.sde"
#i want to change the version of the workspace_sde
edit = arcpy.da.Editor(workspace_sde)
edit.startEditing(False, True)
edit.startOperation()
save_edit=False
icur = arcpy.da.InsertCursor(ic_layer, ic_flds)
for row in new_features:
icur.insertRow(row)
save_edit=True
del icur
edit.stopOperation()
edit.stopEditing(save_edit)
I might can address your issue.
1. You need to activate saved username and password when you created sde connection. At the same time you need to go to geodatabase connection properties to set your version. Since no arcpy modul currently can change the version of file. So if you have a lot of version, you need to create a lot of sde and config their version accordingly.
2. While do version editing, better use with python module
with arcpy.da.Editor(os.path.dirname(students), multiuser_mode=True): # If all 3 edit operations run successfully without error # upon exiting this code block the edits will be applied to the data
arcpy.management.CalculateField(new_students , 'arrived', '2022')
arcpy.management.Append(new_students, students)
arcpy.management.CalculateField(students, "active", True)
source = Editor—ArcGIS Pro | Documentation