Hi,I'm working with the arcpy.da module for the first time and just trying to get a handle on how it operates. I have a PostgreSQL database with a simple table that includes these fields: id, field1, field2, field3, field4. At this point the table is not registered with the geodatabase or SDE (I want to do simple unversioned table edits). For the most part I've been trying to follow the ArcGIS 10.1 help examples.I have been able to successfully use arpy.da.SearchCursor to list records. This works: # List records using search cursor (snippet) table_to_select_from = r"/home/engine/scripts/connections/ARCSDE101-DEV1-PG-DC-GDRS_DEV-GDRS-DEFAULT.sde\gdrs_dev.gdrs.test_arcpy_da" field_list = ["id", "field1", "field2", "field3", "field4"] try: with arcpy.da.SearchCursor(table_to_select_from, field_list) as search_cursor: for row in search_cursor: print("{0}, {1}, {2}, {3}, {4}".format(row[0], row[1], row[2], row[3], row[4])) except Exception as err: print(err) exit(1)
I can also successfully insert new records using arcpy.da.InsertCursor:# Insert record (snippet): table_to_insert_into = r"/home/engine/scripts/connections/ARCSDE101-DEV1-PG-DC-GDRS_DEV-GDRS-DEFAULT.sde\gdrs_dev.gdrs.test_arcpy_da" field_list = ["field1", "field2", "field3", "field4"] values_list = ["Test arcpy.da.insertRow", "Hello World!", 10, "2013-03-23"] try: with arcpy.da.InsertCursor(table_to_insert_into, field_list) as insert_cursor: insert_cursor.insertRow(values_list) except Exception as err: print(err) exit(1)
So far so good. However when I attempt to update rows, I cannot successfully create an update cursor. The exception message: "create cursor has failed" is returned. I'm sure this is something simple, but I've been banging my head on it and hope you can help point me in the right direction. In this example I attempt to multiply the value in an integer field by 2:table_to_update = r"/home/engine/scripts/connections/ARCSDE101-DEV1-PG-DC-GDRS_DEV-GDRS-DEFAULT.sde\gdrs_dev.gdrs.test_arcpy_da" field_list = ["field3"] try: with arcpy.da.UpdateCursor(table_to_update, field_list) as update_cursor: for row in update_cursor: row[0] = row[0] * 2 update_cursor.updateRow(row) del row, update_cursor except Exception as err: print(err)
the string object err which is printed is: "create cursor has failed"I tried placing this block inside an arcpy.da.Editor block, but no change in the error result.Any thoughts? Thank you!