In QGIS 3.16.5-Hannover, with PyQGIS I want to get the provider name of a selected layer. I need to know if it's an ESRI Shapefile
layer or a PostGIS
layer for example.
I don't see how to get this value in QgsProviderRegistry
, or in QgsVectorDataProvider
.
I try this:
# Get the name of a selected layer from a combo box
selectedLayerName = self.mMapLayerComboBox.currentText()
layer = QgsProject.instance().mapLayersByName(selectedLayerName)[0]
# Could it be something like this ?
layerProvider = layer.getProvider()
Is there a way with PyQGIS to know the provider of a selected vector layer? (like metadata information)
PyQGIS
? (ESRI Shapefile
,PostGIS
...)