Select to view content in your preferred language

Calculating a field in a versioned geodatabase. What is the best method?

3819
2
Jump to solution
04-05-2015 09:41 PM
AdamCrateau1
Regular Contributor

I need to update one field, AnnotationClassID, for all annotation in our versioned SDE.  There are close to a million records in a half dozen feature classes.  What are the ramifications of using the arcpy.da module to do this task? Curious to know how others have handled this task.  Below is a basic sketch of what I had in mind.  Many Thanks!

import arcpy
import os

fc = r'X:\Database connection to vm-sql3.sde\Anno0100scale'
workspace = os.path.dirname(fc)

edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()

cursor = arcpy.UpdateCursor(fc, ["AnnotationClassID","SymbolID"])
for row in cursor:
  row.AnnotationClassID = row.SymbolID
  cursor.updateRow(row)

edit.stopOperation()
edit.stopEditing(True)
Tags (2)
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

Hi Adam,

Using the arcpy.da module will be much faster.  Ex:

cursor = arcpy.da.UpdateCursor(fc, ["AnnotationClassID","SymbolID"])
for row in cursor:  
    row[0] = row[1] 
    cursor.updateRow(row) 

Before running this script, I would recommend creating a database backup.  Also, after the edits are complete, it will be best to perform a reconcile/post, compress, and analyze of the datasets.

View solution in original post

2 Replies
GloriaTshokama
Deactivated User

great

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Hi Adam,

Using the arcpy.da module will be much faster.  Ex:

cursor = arcpy.da.UpdateCursor(fc, ["AnnotationClassID","SymbolID"])
for row in cursor:  
    row[0] = row[1] 
    cursor.updateRow(row) 

Before running this script, I would recommend creating a database backup.  Also, after the edits are complete, it will be best to perform a reconcile/post, compress, and analyze of the datasets.