I am using ArcGIS 10.5 in an ArcSDE environment.
I have two tables, they are the exact same table schemas, but one is being edited and those edits are being pushed to the main table. I am a little weak in my python (but learning) and I just started to work with da.cursors and I have gotten this script to work, but both tables have 3800 records in them, and when this runs to update it takes 4 hours. This is just way too long imho.
I am pretty sure I am doing something wrong here but I dont know what it is. Also I am open to any other suggestions on how to best accomplish this task. Some people have suggested joining the two tables based on the UUID and then using the calculate tool to copy over all values, some have suggested using a dictionary.
I also think I dont need the whole arcpy.da.Editor part, but that was in the code sample I found, so I was a little confused.
Please dont feel like I am asking anyone to do this for me, I have gotten this to actually work, but it works very poorly and I am afraid my logic is not very elegant and may actually cause problems later on (like locked dbs, etc...) I would just like a critique of the code and any suggestions on how to better accomplish this.
here is my code
Dump_FC = r'C:\Users\ME\Documents\ArcGIS\Default.gdb\CondemnationTimeline_UUID_xls_CondemnationTimeline_UUID' Main_FC = r'Database Connections\IS memvmtestsql3.XXX.ad.sde\IS_GDB.GISADMIN.PW_CodeEnforcement_CondemnationTimeline' #Load all field names into list named field_names (crazy huh?) dsc = arcpy.Describe(Dump_FC) fields = dsc.fields field_names =  #Remove any field named ObjectID or ObjectID_1 and create list of fields for field in fields: if field.name != "OBJECTID" and field.name != "OBJECTID_1" : print field.name + " != " + dsc.OIDFieldName + " " + str(field.name != dsc.OIDFieldName) field_names.append(field.name) else: continue fc1 = r'C:\Users\XXX\Documents\ArcGIS\Default.gdb\CondemnationTimeline_UUID_xls_CondemnationTimeline_UUID' fc1_fields = field_names fc2 = r'Database Connections\IS memvmtestsql3.XXXX.ad.sde\IS_GDB.GISADMIN.PW_CodeEnforcement_CondemnationTimeline' fc2_fields = field_names # The Editor class allows use of edit sessions and operations to manage database transactions. edit = arcpy.da.Editor(workspace) edit.startEditing(True, False) edit.startOperation() i=1 print "starting main table update" # Open an da.updateCursor on FC1 starting at ROW1 , at ROW1 open second da.updateCursor on FC2 and go ROW by ROW looking for matching GRID # with arcpy.da.UpdateCursor(fc1, fc1_fields) as cur: for row in cur: cur2 = arcpy.da.UpdateCursor(fc2, fc2_fields) print "on row ==================== " + str(i) + " " + str(row) i = i + 1 for row2 in cur2: print row2 if row == row2: # if UUIDS in FC1 match FC2 then copy over all columns print "*** match found ***" j = 0 while j < len(field_names): row2[j] = row[j] j = j + 1 cur2.updateRow(row2) del cur, cur2, row, row2 edit.stopOperation() edit.stopEditing(True)