GeoEco.Datasets.InsertCursor

class GeoEco.Datasets.InsertCursor(dataset, rowCount, reportProgress, rowDescriptionSingular, rowDescriptionPlural)

Bases: _Cursor

Base class for forward-only cursors used to insert rows into a Table.

Not all Tables support insert cursors. To determine if a Table instance supports insert cursors, call its TestCapability() method with a capability of 'InsertCursor'.

This class is not meant to be instantiated directly. Instead call Table.OpenInsertCursor(). After obtaining an InsertCursor instance, call SetValue() and SetGeometry() to set the values of the first row and then call InsertRow() to insert it. Repeat this pattern until you are finished inserting rows. Then close the cursor either by releasing all references to the InsertCursor instance or by explicitly calling its Close() method.

If you do not explicitly set values of all of a new row’s fields by calling SetValue() prior to calling InsertRow(), those fields will be set to database NULL (if they are not read-only). If a field that has not been set is not nullable, InsertRow() will report an error. To determine if a field is nullable, call GetFieldByName() on the Table and examine the IsNullable property of the returned Field instance.

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 Table you are working with.

The typical pattern for using InsertCursor looks like this:

with table.OpenInsertCursor(...) as cursor:
    for ...:                    # Loop over new rows, inserting one at a time
        cursor.SetValue(...)
        ...
        cursor.InsertRow()

Properties

property IsOpen

(bool) True if the cursor is open, False if it is closed. 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.

property Table

(Table) Table the cursor is accessing. Read only.

Methods

Close

Closes the cursor.

InsertRow

Submits the new row to the underlying data store.

SetGeometry

Sets the geometry of the new row.

SetRowCount

Sets the number of rows that this cursor is expected to process.

SetValue

Sets the value of a field of the new row, given the name of the field and its value.