Not sure what the issues is but I am trying to use arcpy.da.InsertCursor on a SDE feature class but keep getting the 'Can't open workspace' error.The feature-dateset is versioned.
edit = arcpy.da.Editor(workspace)
RuntimeError: cannot open workspace
fc = r"C:\Users\***\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog\***_***_***.sde\***.***.TEST\C***.***.Test"
workspace = os.path.dirname(fc)
#arcpy.env.workspace = r"C:\\Users\\***\\AppData\\Roaming\\Esri\\ArcGISPro\\Favorites\\Database Connections\\***_***.sde\\***.***.TEST"
#fc = "***.***.Test"
edit = arcpy.da.Editor(workspace)
# Edit session is started without an undo/redo stack for versioned data
# (for second argument, use False for unversioned data)
edit.startEditing(True)
# Start an edit operation
edit.startOperation()
dsc = arcpy.Describe(fc1)
fields = dsc.fields
# List all field names except the OID field
fieldnames = [field.name for field in fields]
# Create cursors and insert new rows
with arcpy.da.SearchCursor(fc1,fieldnames) as sCur:
with arcpy.da.InsertCursor(fc,fieldnames) as iCur:
for row in sCur:
iCur.insertRow(row)
del sCur
# Stop the edit operation.
edit.stopOperation()
# Stop the edit session and save the changes
edit.stopEditing(True)
Solved! Go to Solution.
Well that's a problem too. It should print True