[QGIS-Developer] pyqgis: new sqlite layer - no records in attribute table

Martin Landa landa.martin at gmail.com
Mon Nov 6 07:51:30 PST 2017


Hi,

a new SQLite layer created using Python libraries:

layer = QgsVectorLayer("test.sqlite", "test", "ogr") # empty layer
created by GDAL
layer.dataProvider().addAttributes([...])
layer.updateFields()

feats = []
for ...:
   feat=QgsFeature()
   ...
   feats.append(feat)

layer.AddFeatures(feats)

The new layer is loaded (in pyqgis code), features can be identified,
but attribute table is empty (0 filtered features), see attached
screenshot [1]. When I load created SQLite layer via GUI, attribute
table is filled.

Any idea what is missing/wrong in code? Thanks, Ma

[1] http://geo102.fsv.cvut.cz/~landa/tmp/qgis-no-attrs.png

-- 
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa


More information about the QGIS-Developer mailing list