Subgroup: Data
Class: QgsDataProvider¶
-
class
qgis.core.
QgsDataProvider
¶ Bases:
PyQt5.QtCore.QObject
Abstract base class for spatial data provider implementations.
This object needs to inherit from QObject to enable event processing in the Postgres/PostGIS provider (QgsPostgresProvider). It is called here so that this vtable and the vtable for QgsPostgresProvider don’t get misaligned - the QgsVectorLayer class factory (which refers to generic QgsVectorDataProvider’s) depends on it.
Methods
appendError
Add error message blockSignals
childEvent
children
connectNotify
crs
Returns the coordinate system for the data source. customEvent
dataSourceUri
Get the data source specification. dataTimestamp
Current time stamp of data source deleteLater
description
Return description disconnect
disconnectNotify
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
enterUpdateMode
Enter update mode. error
Get current status error. event
eventFilter
extent
Returns the extent of the layer fileRasterFilters
Return raster file filter string fileVectorFilters
Return vector file filter string findChild
findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject findChildren
findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] inherits
installEventFilter
invalidateConnections
Invalidate connections corresponding to specified name isSignalConnected
isValid
Returns true if this is a valid layer. isWidgetType
isWindowType
killTimer
leaveUpdateMode
Leave update mode. metaObject
moveToThread
name
Return a provider name objectName
parent
property
providerProperty
Get the current value of a certain provider property. pyqtConfigure
Each keyword argument is either the name of a Qt property or a Qt signal. receivers
reloadData
Reloads the data from the source. removeEventFilter
sender
senderSignalIndex
setDataSourceUri
Set the data source specification. setError
Set error message setLayerOrder
Reorder the list of layer names to be rendered by this provider setListening
Set whether the provider will listen to datasource notifications If set, the provider will issue notify signals. setObjectName
setParent
setProperty
setProviderProperty
Allows setting arbitrary properties on the provider. setSubLayerVisibility
Set the visibility of the given sublayer name setSubsetString
Set the subset string used to create a subset of features in the layer. setUri
Set the data source specification. signalsBlocked
startTimer
subLayerCount
return the number of layers for the current data source subLayerStyles
Sub-layer styles for each sub-layer handled by this provider, subLayers
Sub-layers handled by this provider, in order from bottom to top subsetString
Returns the subset definition string (typically sql) currently in use by the layer and used by the provider to limit the feature set. supportsSubsetString
Returns true if the provider supports setting of subset strings. thread
timerEvent
timestamp
Time stamp of data source in the moment when data/metadata were loaded by provider tr
updateExtents
Update the extents of the layer. uri
Get the data source specification. Attributes
CustomData
Database
Dir
EvaluateDefaultValues
File
Net
NoDataCapabilities
SUBLAYER_SEPARATOR
dataChanged
This is emitted whenever an asynchronous operation has finished destroyed
destroyed(self, QObject = None) [signal] fullExtentCalculated
This is emitted whenever the worker thread has fully calculated the PostGIS extents for this layer, and its event has been received by this provider. notify
Emitted when datasource issues a notification objectNameChanged
objectNameChanged(self, str) [signal] staticMetaObject
-
CustomData
= 3000¶
-
class
DataCapability
¶ Bases:
int
-
Database
= 4¶
-
Dir
= 2¶
-
EvaluateDefaultValues
= 0¶
-
File
= 1¶
-
Net
= 8¶
-
NoDataCapabilities
= 0¶
-
class
ProviderProperty
¶ Bases:
int
-
SUBLAYER_SEPARATOR
= '!!::!!'¶
-
appendError
(self, message: QgsErrorMessage)¶ Add error message
-
childEvent
()¶
-
connectNotify
()¶
-
crs
(self) → QgsCoordinateReferenceSystem¶ Returns the coordinate system for the data source. If the provider isn’t capable of returning its projection then an invalid QgsCoordinateReferenceSystem will be returned.
-
customEvent
()¶
-
dataChanged
¶ This is emitted whenever an asynchronous operation has finished and the data should be redrawn
When emitted from a
QgsVectorDataProvider
, any cached information such as feature ids should be invalidated. [signal]
-
dataSourceUri
(self, expandAuthConfig: bool = False) → str¶ Get the data source specification. This may be a path or database connection string
Parameters: expandAuthConfig – Whether to expand any assigned authentication configuration Returns: data source specification Note
The default authentication configuration expansion is FALSE. This keeps credentials out of layer data source URIs and project files. Expansion should be specifically done only when needed within a provider
-
dataTimestamp
(self) → QDateTime¶ Current time stamp of data source
-
description
(self) → str¶ Return description
Return a terse string describing what the provider is.
note
Instead of being pure virtual, might be better to generalize this behavior and presume that none of the sub-classes are going to do anything strange with regards to their name or description?
-
disconnectNotify
()¶
-
enterUpdateMode
(self) → bool¶ Enter update mode.
This is aimed at providers that can open differently the connection to the datasource, according it to be in update mode or in read-only mode. A call to this method shall be balanced with a call to leaveUpdateMode(), if this method returns true.
Most providers will have an empty implementation for that method.
For backward compatibility, providers that implement enterUpdateMode() should still make sure to allow editing operations to work even if enterUpdateMode() is not explicitly called.
Several successive calls to enterUpdateMode() can be done. So there is a concept of stack of calls that must be handled by the provider. Only the first call to enterUpdateMode() will really turn update mode on.
Returns: true in case of success (or no-op implementation), false in case of failure. New in version 2.16.
-
error
(self) → QgsError¶ Get current status error. This error describes some principal problem for which provider cannot work and thus is not valid. It is not last error after accessing data by block(), identify() etc.
-
extent
(self) → QgsRectangle¶ Returns the extent of the layer
Returns: QgsRectangle containing the extent of the layer
-
fileRasterFilters
(self) → str¶ Return raster file filter string
Returns a string suitable for a QFileDialog of raster file formats supported by the data provider. Naturally this will be an empty string for those data providers that do not deal with plain files, such as databases and servers.
Note
It’d be nice to eventually be raster/vector neutral.
-
fileVectorFilters
(self) → str¶ Return vector file filter string
Returns a string suitable for a QFileDialog of vector file formats supported by the data provider. Naturally this will be an empty string for those data providers that do not deal with plain files, such as databases and servers.
Note
It’d be nice to eventually be raster/vector neutral.
-
fullExtentCalculated
¶ This is emitted whenever the worker thread has fully calculated the PostGIS extents for this layer, and its event has been received by this provider. [signal]
-
invalidateConnections
(self, connection: str)¶ Invalidate connections corresponding to specified name
New in version 2.16.
-
isSignalConnected
()¶
-
isValid
(self) → bool¶ Returns true if this is a valid layer. It is up to individual providers to determine what constitutes a valid layer.
-
leaveUpdateMode
(self) → bool¶ Leave update mode.
This is aimed at providers that can open differently the connection to the datasource, according it to be in update mode or in read-only mode. This method shall be balanced with a successful call to enterUpdateMode().
Most providers will have an empty implementation for that method.
Several successive calls to enterUpdateMode() can be done. So there is a concept of stack of calls that must be handled by the provider. Only the last call to leaveUpdateMode() will really turn update mode off.
Returns: true in case of success (or no-op implementation), false in case of failure. New in version 2.16.
-
name
(self) → str¶ Return a provider name
Essentially just returns the provider key. Should be used to build file dialogs so that providers can be shown with their supported types. Thus if more than one provider supports a given format, the user is able to select a specific provider to open that file.
note
Instead of being pure virtual, might be better to generalize this behavior and presume that none of the sub-classes are going to do anything strange with regards to their name or description?
-
notify
¶ Emitted when datasource issues a notification
See also
New in version 3.0: [signal]
-
providerProperty
(self, property: QgsDataProvider.ProviderProperty, defaultValue: Any = None) → Any¶ Get the current value of a certain provider property. It depends on the provider which properties are supported.
New in version 2.16.
-
receivers
()¶
-
reloadData
(self)¶ Reloads the data from the source. Needs to be implemented by providers with data caches to synchronize with changes in the data source
-
sender
()¶
-
senderSignalIndex
()¶
-
setDataSourceUri
(self, uri: str)¶ Set the data source specification. This may be a path or database connection string
Parameters: uri – source specification
-
setError
(self, error: QgsError)¶ Set error message
-
setLayerOrder
(self, layers: Iterable[str])¶ Reorder the list of layer names to be rendered by this provider (in order from bottom to top)
Note
layers must have been previously added.
-
setListening
(self, isListening: bool)¶ Set whether the provider will listen to datasource notifications If set, the provider will issue notify signals.
The default implementation does nothing.
See also
New in version 3.0.
-
setProviderProperty
(self, property: QgsDataProvider.ProviderProperty, value: Any)¶ Allows setting arbitrary properties on the provider. It depends on the provider which properties are supported.
New in version 2.16.
-
setSubLayerVisibility
(self, name: str, vis: bool)¶ Set the visibility of the given sublayer name
-
setSubsetString
(self, subset: str, updateFeatureCount: bool = True) → bool¶ Set the subset string used to create a subset of features in the layer. This may be a sql where clause or any other string that can be used by the data provider to create a subset. Must be implemented in the dataprovider.
-
setUri
(self, uri: QgsDataSourceUri)¶ Set the data source specification.
New in version 3.0.
-
subLayerCount
(self) → int¶ return the number of layers for the current data source
-
subLayerStyles
(self) → List[str]¶ Sub-layer styles for each sub-layer handled by this provider, in order from bottom to top
Sub-layer styles are used to abstract the way the provider’s source can symbolise layers in some way at the server, before it serves them to the provider.
-
subLayers
(self) → List[str]¶ Sub-layers handled by this provider, in order from bottom to top
Sub-layers are used when the provider’s source can combine layers it knows about in some way before it hands them off to the provider.
See also
SUBLAYER_SEPARATOR
-
subsetString
(self) → str¶ Returns the subset definition string (typically sql) currently in use by the layer and used by the provider to limit the feature set. Must be overridden in the dataprovider, otherwise returns a null QString.
-
supportsSubsetString
(self) → bool¶ Returns true if the provider supports setting of subset strings.
-
timerEvent
()¶
-
timestamp
(self) → QDateTime¶ Time stamp of data source in the moment when data/metadata were loaded by provider
-
updateExtents
(self)¶ Update the extents of the layer. Not implemented by default.
-
uri
(self) → QgsDataSourceUri¶ Get the data source specification.
New in version 3.0.
-