GeoEco.Datasets.UpdateCursor
- class GeoEco.Datasets.UpdateCursor(dataset, fields, where, orderBy, rowCount, reportProgress, rowDescriptionSingular, rowDescriptionPlural)
Bases:
SelectCursorBase class for forward-only cursors used to read, update, or delete rows in a
Table.Not all
Tables support update cursors. To determine if aTableinstance supports update cursors, call itsTestCapability()method with a capability of'UpdateCursor'. SomeTables that support update cursors only support updating rows, not deleting them, or visa versa. To check this, test the'UpdateRow'and'DeleteRow'capabilities of theTableinstance.This class is not meant to be instantiated directly. Instead call
Table.OpenUpdateCursor(). After obtaining aUpdateCursorinstance, callNextRow()to advance the cursor to the first row. IfNextRow()returns True, use the functions discussed below to read, update, or delete the row. CallNextRow()again to advance to the next row. WhenNextRow()returns False, no rows remain and the cursor is closed. The cursor is also closed automatically if theUpdateCursorinstance is deleted, and you can explicitly close it withClose().To read values from the row, use
GetValue(),GetGeometry(), andGetOID(). To update values, useSetValue()andSetGeometry()and then, after updating all fields of interest, callUpdateRow(). After callingUpdateRow(), do not do anything else with the row, just callNextRow()to go on to the next one. To delete a row, callDeleteRow()and thenNextRow().Certain storage formats may implement a transactional updating scheme in which changes will not be committed to the underlying data store until the cursor has been closed. For more information, please see the documentation for the particular kind of
Tableyou are working with.The typical pattern for using
UpdateCursorlooks like this:with table.OpenUpdateCursor(...) as cursor: while cursor.NextRow(): value = cursor.GetXXXXX(...) ... if <need to update this row>: cursor.SetXXXXX(...) ... cursor.UpdateRow() elif <need to delete this row>: cursor.DeleteRow()
Properties
- property AtEnd
(
bool) If True, no more rows are available (andIsOpenwill also be False). If False, more rows may be available. Read only.
- property RowDescriptionPlural
(
str) Word to use in progress and error messages for plural rows. If not supplied when the cursor was opened, an appropriate generic word will be automatically selected based on table’s geometry type, such as “points”, “lines”, “polygons”, and so on. If the table does not have geometry, “rows” will be used. Read only. Minimum length꞉ 1.
- property RowDescriptionSingular
(
str) Word to use in progress and error messages for a single row. If not supplied when the cursor was opened, an appropriate generic word will be automatically selected based on the table’s geometry type, such as “point”, “line”, “polygon”, and so on. If the table does not have geometry, “row” will be used. Read only. Minimum length꞉ 1.
Methods
Closes the cursor.
Deletes the current row.
Retrieves the geometry of the current row.
Retrieves the ArcGIS "object ID" of the current row.
Retrieves the value of a field of the current row, given the name of the field.
Advances the cursor to the next row.
Sets the geometry of the current row.
Sets the number of rows that this cursor is expected to process.
Sets the value of a field of the current row, given the name of the field and its new value.
Submits any changes made to the current row to the underlying data store.