[Qgis-developer] Get name FID of vector Layer
Luiz Motta
motta.luiz at gmail.com
Fri Feb 18 13:20:25 EST 2011
Devs,
I need get the name field of Feature Index of vector file.
For Shapefile provider, i can use the string "FID".
But, the database provider, example Postgis or Spatialite, i need find
the name field of Primary key use for FID.
I don't find the methods in classes QgsVectorLayer and QgsDataprovider
In OGR i have the method "GetFIDColumn" (i don't test).
The idea is add in canvas the layer with FID's selected from layer.
The example of script to use in python console QGIS:
from qgis import core, gui
lyr = qgis.utils.iface.mapCanvas().currentLayer()
addLyr = core.QgsVectorLayer(lyr.source(), "test_subset", lyr.providerType())
addLyr.setSubsetString("FID IN (0,1,2)")
core.QgsMapLayerRegistry.instance().addMapLayer(addLyr)
The script run in shapefile, but, i need find the name of "Key" in
layer from database.
Regards,
Luiz Motta
More information about the Qgis-developer
mailing list