Strange Error While Using arcpy.da.UpdateCursor on SDE

1512
5
02-16-2022 05:55 AM
by Anonymous User
Not applicable

I ran the following code on a gdb target and it worked just fine. Now that I've redirected at an SDE target I am getting an ambiguous error: 

 

 

def edit_feature_class(structure_data,workspace):
    fc = "Target Feature"
    fields = ["Target Field"]
    descriptions = structure_data["Target Field"].tolist()
    with arcpy.da.Editor(workspace) as edit:
        with arcpy.da.UpdateCursor(fc, fields) as cursor:
            i=0
            for row in cursor:
                row[0] = descriptions[i]
                cursor.updateRow(row)
                i = i+1

 

 

 The error it throws is: with arcpy.da.UpdateCursor(fc, fields) as cursor TypeError Cannot update table

 

Any help is appreciated, 

Thank you

 

f

0 Kudos
5 Replies
DonMorrison1
Occasional Contributor III

Is "Target Field" really the field name or is it an alias? I think some databases don't allow spaces in the field names....

If the failure is on the updateRow I would add some print or AddMessage statements to dump out descriptions[i] to see which record it is choking on and the contents of the field at that point. 

by Anonymous User
Not applicable

Target Field just a dumby name I'm using for the purposes of the question, the real name is a single word. The failure is on 

with arcpy.da.UpdateCursor(fc, fields) as cursor:

 

DonMorrison1
Occasional Contributor III

Another idea is to start removing fields from the list  until is starts working, or try a SearchCursor on that feature class- perhaps with just the ['objectid'] field to start with ( assuming you have  field called that).  

0 Kudos
DanPatterson
MVP Esteemed Contributor

fc  ... is that the full path to the featureclass?

fields ... you have confirmed the field names?

as for the cursor, do you have permissions to create one for the source file?


... sort of retired...
0 Kudos
Cristian_Galindo
Occasional Contributor III

Hi fellow, 

to be hones I do not trust yet in the implementation of arcpy for the use of objects with the function "with",

I would strongly suggest to go in the direction of the old school and use the methods of the editor object:

startOperation ()
stopOperation ()
abortOperation ()
undoOperation ()
0 Kudos