I am still learning python and arcpy. I have spent too much time trying to figure out this code. I need help. What I have is two feature classes that have the same column names. One has older data than the other. FC1 has data that has 8 relationships (feature linked annotation). The FC2 is a master layer that gets update so attributes change. I cannot just swap fc's because the feature linked annotation is on a live web service.
I tried to use Calculate Field in an Arcmap session (found out it has to be in an edit session). I started the Calculate Field and it ran for over 20 hours and I had to kill the session. I have to update 10 columns.
I am tried to do this in Python with arcpy.CalculateField_management. Doesn't work and I posted a question. It was recommended to use cursors. The problem is I keep getting an error message that "Objects in this class cannot be updated outside an edit session [ttp.ttp.tintp_1]"
Here is my code:
import traceback import arcpy from arcpy import env import os anno_conn = "\\\\path\\Connection to database.sde" env.workspace = anno_conn #Variables Table_A = "tintp_1" Table_B = "tintp_r3" fieldlist = ["link_id"] workspace = os.path.dirname(anno_conn) try: with arcpy.da.Editor(workspace) as edit: prows = arcpy.SearchCursor(Table_B) for prow in prows: prior = prow.getValue("prior_visi") field = prow.getValue(fieldlist) print (str(prior) + " " + str(field)) rows = arcpy.UpdateCursor(Table_A, "visi_link = " + str(prior)) for row in rows: row.setValue(fieldlist, field) rows.updateRow(row) print "updated row" del row del rows del prow del prows except Exception, err: traceback.print_exc()
Any help would be greatly appreciated. This has my experienced colleagues stumped as well.