AnsweredAssumed Answered

Help with BUG-000094056 Workaround

Question asked by LarryAdgate on Apr 4, 2018
Latest reply on Apr 4, 2018 by Dan_Patterson

Except for some of the workaround scripting provided to me by ESRI, this script works great on my desktop but not on my SQL Server. From talking with ESRI about this,  they are reporting that I am hitting a bug (BUG-000094056).  The ESRI quote is as follows: The arcpy.da.Editor class does not properly utilize an edit session to edit feature classes participating in a composite relationship class when the 'with' statement is used. As follows is their suggested workaround: (Unfortunately, I cannot get the work around to work: My ERROR: RuntimeError: cannot open workspace)

  • Explicitly open an edit session and operation: 
    # Start an edit session. Must provide the workspace. 
    edit = arcpy.da.Editor(arcpy.env.workspace) 
    # Start an edit session. 
    edit.startEditing(False,False) 
    # Start an edit operation. 
    edit.startOperation() 
    # Edit the data. 
    (This would be where your update script would go)

# Stop the edit operation. 
edit.stopOperation() 
# Stop the edit session and save the changes. 
edit.stopEditing(True)

 

Is there a way to get the workaround to work?

Thank You, Larry Adgate

 

import arcpy

# Start an edit session. Must provide the workspace. 
workspace = "arcpy.env.workspace.Database Connections\\TaskmasterServer.sde"
edit = arcpy.da.Editor(workspace)

# Start an edit session.
edit.startEditing(False,False)

# Start an edit operation.
edit.startOperation()

# above is some of the work around stuff and below is my script.
newfc = "sde_gsw.GSW_SDE.CCB_Data\\sde_gsw.GSW_SDE.Master_CCB_Points"
basefc = "sde_gsw.GSW_SDE.CCB_Data\\sde_gsw.GSW_SDE.CCB_ServiceLines"

# empty dictionary
dict = {}

# read PREM_ID as key and coordinates
with arcpy.da.SearchCursor(newfc,['PREM_ID','SHAPE@X','SHAPE@Y']) as cur:
for row in cur:
dict[row[0]]= {'x':row[1],'y':row[2] }

# update old feature
with arcpy.da.UpdateCursor(basefc,['PREM_ID','SHAPE@X','SHAPE@Y']) as upCur:
for row in upCur:
# if PREM_ID is in dictionary, update x,y else skip update
if row[0] in dict:
row[1] = dict[row[0]]['x']
row[2] = dict[row[0]]['y']
upCur.updateRow(row)
print "Updated {}".format(row[0])

 

#Below is more workaround stuff

#Stop the edit operation. 
edit.stopOperation()

#Stop the edit session and save the changes.
edit.stopEditing(True)

Outcomes