I am making my first attempt at editing an ArcSDE feature class with python through a da.UpdateCursor. I'm essentially taking code I've written for a file geodatabase feature class and applying it to an SDE feature class. Doing so produces an error, and I'm not sure how to rectify the problem.

I'm using ArcGIS 10.1 for Desktop.

Pertinent code:

Struxfeature = r"DatabaseConnections\PipelinePathways.sde\PPGIS.Strux\PPGIS.StruxPts_v04_all"
P6feature = r"DatabaseConnections\PipelinePathways.sde\PPGIS.Strux\PPGIS.Land_Projects_Parcels_P6"

SDE = r"Database Connections\PipelinePathways.sde"
UserID = "E1B8"
Parent = "SDE.DEFAULT"
version = "change_RW_VC_4447_14_to_C"

#Create Version
print "Creating version"
arcpy.CreateVersion_management(SDE, Parent, version, "PUBLIC")
VersionName = UserID.upper() + "." + version

arcpy.MakeFeatureLayer_management (Struxfeature, "Struxlyr")
arcpy.MakeFeatureLayer_management (P6feature, "P6lyr")

#Switch to version
print "Switching version"
arcpy.ChangeVersion_management("Struxlyr", "TRANSACTIONAL", VersionName)
arcpy.ChangeVersion_management("P6lyr", "TRANSACTIONAL", VersionName)

#Start editing
print "Initiating editing"
edit = arcpy.da.Editor(SDE)

# Start an edit operation

#Change P6 project numbers   
print "Updating P6.\n"
P6Cursor = arcpy.da.UpdateCursor ("P6lyr", ["P6_NBR", "Name"])
for row in P6Cursor:

The error comes from the line 'for row in P6Cursor:'

Traceback (most recent call last):
  File "C:\E1B8\ScriptTesting\ScriptsIUse\ChangeP6.py", line 81, in <module>
    for row in P6Cursor:
RuntimeError: workspace already in transaction mode
  • You are changing your version to UserID.upper() + "." + version but creating a version called "change_RW_VC_4447_14_to_C", is this intentional? I suspect that your problem may arise from edit.StartEditing, which has two optional parameters, multiuser_mode defaults to True but may need to be False. Consider using with statements for your edit and cursor to help tidy them up when you're finished. Commented Oct 28, 2014 at 1:54
  • Thanks for the comment. Indeed, to access a created version the format for my VersionName variable is correct. I have read about with statements quite a bit but have not quite started incorporating them into my scripts. I'll work on it. Changing multiuser_mode in edit.StartEditing to False did not change the resulting error. Commented Oct 28, 2014 at 16:54
  • What underlying database are you using? If you are using PostgreSQL or other database that allows multiple databases perhaps create a test database and try it without the versioning / without the startEditing-startOperation... take the code back to simplest forms until you discover where the problem is occuring. If that isn't an option (you are using Oracle or similar single database) you may need to contact Esri support for a better explanation of what's happening and probable solution. Commented Oct 28, 2014 at 22:07
  • It is an Oracle database. If my code is right, I'll talk to the SDE IT folks. Commented Oct 28, 2014 at 22:38
  • I think you will find answers to this easier to come by if you can treat this as three separate questions. For each, I would focus on providing a code snippet that leads to the error message. I would ask about the one you think is most important or likely to be able to assist you past your blocking point first.
    – PolyGeo
    Commented Oct 29, 2014 at 21:46

4 Answers 4


With help I have found my solution, though the reasoning behind it is a bit blurry currently. In my code, creating a version through one SDE connection file and then creating the feature layer to be edited through another SDE connection file that is connected to the new version works. Also, edit.startEditing must have the variable 'multiuser_mode' set to true (the default). As I understand it, this variable indicates whether there can be multiple versions/users allowed for the layer. Since this is always true for an SDE feature layer, setting this variable to False causes an error.

Functioning code, where I test an update cursor:

import arcpy
import os
P6featureName = r"PPGIS.Strux\PPGIS.Land_Projects_Parcels_P6"
Parent = "SDE.DEFAULT"
version = "SDE_Test"
Server = ***
Service = ***
user = ***
Pass = ***
SDE = "Database Connections\PipelinePathways.sde"
temploc = r"C:\E1B8\ScriptTesting\Workspace"
fil = "SDETempConn"

env.overwriteOutput = True

#Create Version
print "Creating version"
arcpy.CreateVersion_management (SDE, Parent, version, "PUBLIC")
VersionName = user.upper() + "." + version

#Create new connection
workspace = os.path.join (temploc, fil + ".sde")
print "Creating SDE connection"
arcpy.CreateArcSDEConnectionFile_management (temploc, fil, Server, Service, username = user, password = Pass, version = VersionName)

P6feature = os.path.join (workspace, P6featureName)
arcpy.MakeFeatureLayer_management (P6feature, "P6lyr")

#Start editing
print "Initiating editing"
edit = arcpy.da.Editor (workspace)
edit.startEditing ()

#Test Cursor
print "Testing cursor"
P6Cursor = arcpy.da.UpdateCursor ("P6lyr", ["NAME"])
for row in P6Cursor:
    print row[0]
del row
del P6Cursor

#Stop/save edits
print "Stopping editing"

#Switch to version
print "Switching version"
arcpy.ChangeVersion_management("P6lyr", "TRANSACTIONAL", Parent)

#Reconcile and post
print "Reconciling and posting"
arcpy.ReconcileVersions_management (workspace, "", Parent, VersionName, with_post = "POST", with_delete = "DELETE_VERSION")

Thanks to Ben Nadler for the help.


In my case the table we were inserting into was not registered with the geodatabase and was never going to be registered. Adding a primary key and identity column resolved this issue for us.


I've run into the same problem: "workspace already in transaction mode". I had Microsoft SQL Server database connected to ArcCatalog as SDE.

And decision in my case was just to change type of column "timestamp" of target table to "image".


I also had that error in my python script while adding new Feature layers. After wasting a lot of time I figured that the layers were not registered. So I registered the layers and got it working .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.