I have two geodatabases, one is a production sde database, the other is a backup in a local file geodatabase. The script runs as a task once a month and is very resource intensive. I am using ArcGIS for Desktop 10 SP 5.

What I would like to do is use a search and update cursor for each feature class in the database, including feature data sets; if there has been any change to the feature class; then just update the backup based on what is in the production instead of deleting it.

The example here shows how to update a feature class based on a field and changes to a field. I would like to parse and update all feature classes in gdb2 if there is a change to a feature class in gdb1. How can this script be modified to meet my needs?

import arcpy

#input feature class
fc2 = r"C:\temp\temp.gdb\fc2"
#target feature class
fc3 = r"C:\temp\temp.gdb\fc3"

#check field
checkField = "SRNumber"

#Get list of values in field from target feature class
checkValues = [r[0] for r in arcpy.da.SearchCursor (fc3, checkField)]

#Get list of fields
fields = [f.name for f in arcpy.ListFields (fc2)]

#Get index of check field
index = fields.index (checkField)

#Create insert cursor for fc3 to allow appending of rows
inCursor = arcpy.da.InsertCursor (fc3, fields)

#Create search cursor to iterate input feature class
cursor = arcpy.da.SearchCursor (fc2, fields)
for row in cursor:
    #Get value to check
    checkValue = row[index]

    #Check if value is in target fc
    if checkValue in checkValues:
        #skip if value is in target fc

    #Insert row otherwise

#Clean up
del cursor
del inCursor
  • 2
    Are you on Desktop 10.0 SP5? I believe the da module was made available at 10.1. With walk it would be simple to iterate over a GDB assuming the structures are identical.
    – Paul
    May 20, 2016 at 18:28
  • I am not on 10.1 .da is not available in Desktop 10.0 May 20, 2016 at 18:40
  • 3
    Why not just replicate the feature class from production to development?
    – alexGIS
    May 20, 2016 at 23:47

1 Answer 1


As alexGIS already said, it would be easiest to create a replica between your SDE database and your local backup fileGDB

Make sure that your SDE database is versioned and all feature classes have a GlobalID. If you want to work with a fileGDB check-in/ check-out replicas is the right choise: http://help.arcgis.com/EN/ARCGISDESKTOP/10.0/HELP/index.html#/Creating_a_check_out_replica/00270000002t000000/

Your Answer

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

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