Class: QgsFeatureSink

class qgis.core.QgsFeatureSink

Bases: sip.wrapper

An interface for objects which accept features via addFeature(s) methods.

New in version 3.0:

Methods

addFeature

Adds a single feature to the sink.

addFeatures

Adds a list of features to the sink.

flushBuffer

Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination.

lastError

Returns the most recent error encountered by the sink, e.g.

Attributes

FastInsert

RegeneratePrimaryKey

RollBackOnErrors

FastInsert = 2
class Flag

Bases: int

class Flags
class Flags(Union[QgsFeatureSink.Flags, QgsFeatureSink.Flag]) None
class Flags(QgsFeatureSink.Flags) None

Bases: sip.wrapper

RegeneratePrimaryKey = 2
RollBackOnErrors = 4
class SinkFlag

Bases: int

class SinkFlags
class SinkFlags(Union[QgsFeatureSink.SinkFlags, QgsFeatureSink.SinkFlag]) None
class SinkFlags(QgsFeatureSink.SinkFlags) None

Bases: sip.wrapper

addFeature(self, feature: QgsFeature, flags: Union[QgsFeatureSink.Flags, QgsFeatureSink.Flag] = QgsFeatureSink.Flags()) bool

Adds a single feature to the sink. Feature addition behavior is controlled by the specified flags.

See also

addFeatures()

Return type

bool

Returns

True in case of success and False in case of failure

Parameters
addFeatures(self, features: Iterable[QgsFeature], flags: Union[QgsFeatureSink.Flags, QgsFeatureSink.Flag] = QgsFeatureSink.Flags()) bool

Adds a list of features to the sink. Feature addition behavior is controlled by the specified flags.

See also

addFeature()

Returns

True in case of success and False in case of failure

addFeatures(self, iterator: QgsFeatureIterator, flags: Union[QgsFeatureSink.Flags, QgsFeatureSink.Flag] = QgsFeatureSink.Flags()) -> bool Adds all features from the specified iterator to the sink. Feature addition behavior is controlled by the specified flags.

Return type

bool

Returns

True if all features were added successfully, or False if any feature could not be added

Parameters
flushBuffer(self) bool

Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink’s destination.

Return type

bool

Returns

False if any buffered features could not be added to the sink.

lastError(self) str

Returns the most recent error encountered by the sink, e.g. when a call to addFeatures() returns False.

New in version 3.16.

Return type

str