Update Cursor not working

399
2
02-12-2014 05:31 AM
JordanParfitt
Occasional Contributor
I have this update cursor. The code executes in LiClipse without an error at all but none of my rows update in SDE. Am I missing a step?

Thanks,
Jordan


# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# stupidtest.py
# Created on: 2014-02-06 11:56:15.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy
import arceditor

arg_sdeDEV_sde = "Database Connections\\arg@sdeDEV.sde"
ARG_ACCESS_OPENING = "Database Connections\\arg@sdeDEV.sde\\ARG.DistributionSystem\\ARG.ACCESS_OPENING"
ACCESS_OPENING_Layer = "ACCESS_OPENING_Layer"

# Process: Make Feature Layer
arcpy.env.workspace = "Database Connections\\arg@sdeDEV.sde"
arcpy.env.overwriteOutput = True
arcpy.MakeFeatureLayer_management(ARG_ACCESS_OPENING, ACCESS_OPENING_Layer, "", arg_sdeDEV_sde, "OBJECTID OBJECTID VISIBLE NONE;OPEN_TYPE OPEN_TYPE VISIBLE NONE;REC_INFO_NAME REC_INFO_NAME VISIBLE NONE")

# Process: Start Edit
edit = arcpy.da.Editor(arcpy.env.workspace)
edit.startEditing(False, True)
edit.startOperation()

# Process: Select and Update Data
cursor = arcpy.UpdateCursor(ARG_ACCESS_OPENING)
for row in cursor:
    if str(row.getValue("STRUCTURE_ID")) == 'None':
        row.STRUCTURE_ID = str(row.getValue("ENCLOSURE_ID"))
        cursor.updateRow(row)
        
del cursor, row
        
print 'done'
Tags (2)
0 Kudos
2 Replies
ClintDow
Occasional Contributor
Maybe an overly simplistic observation, but in:

 if str(row.getValue("STRUCTURE_ID")) == 'None':


Is the 'None' meant to be a string or should it just be None for NoData? The way you have it now the conditional will only trigger if there's actually the string 'None' in those cells.
0 Kudos
JordanParfitt
Occasional Contributor
All of my code is executing. It makes it pass that if statement and even if I remove the if statement it doesn't work either. The database just isn't being updated.


for row in cursor:
    row.STRUCTURE_ID = str(row.getValue("ENCLOSURE_ID"))
    cursor.updateRow(row)


Thank You
0 Kudos