Hello,

I've been further this morning... You just need to build a QgsFeatureRequest which grabs the NoGeometry features.

layer = QgsMapLayerRegistry.instance().mapLayersByName('MY_ATTRIBUTE_TABLE')[0] for f in layer.getFeatures(QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry)):
  print f

This behavior seems to be specific to Oracle NoGeometry QgsVectorLayers. I have made tests under PostGIS and Spatialite and you can use the getFeatures() method without specifying a QgsFeatureRequest to grab all the features of the layer.

Should I file a bug report on Oracle provider ?

Best regards,

Le 2014-12-09 17:47, mederic.ribreux a écrit :
Hello,

I am trying to iterate over a non geographic table under PyQGis. The
table is stored in an Oracle database and I use QGis Api to get the
data (table is opened in a QGis project with Oracle provider). I have
added primary key constraint to this table but I am not able to
iterate through its features with the getFeatures() method. The
following snippet always returns nothing:

layer = QgsMapLayerRegistry.instance().mapLayersByName('MY_ATTRIBUTE_TABLE')[0]
for f in layer.getFeatures():
  print f

I have tried with a geographic layer and there is no problem on this
side because the above snippets prints a line for every feature in the
table. I have also tried with opening the geographic table without
geometry (geometry is "No Geometry"). In this configuration, I am not
able to get access to the features...

I have tried to reproduce this on a PostgreSQL/PostGIS server and
there is no bug: I am able to iterate over a non-geographic layer
(even a geographic layer declared as non-geographic).

Is this a problem with the Oracle provider or just me having forgotten
something in the table ?

Best regards

--
Médéric RIBREUX
http://medspx.homenet.org
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to