I would like to duplicate an entry in QGIS (2.18.21) layer_styles
table (in a PostGIS database) by the following steps:
From a PostGIS connection with styles saved to database add layer_styles
table to the project and select it in the layers panel.
Using the following code on the python console I try to duplicate one of the features in the table:
>>> l = iface.activeLayer()
>>> f = [f for f in l.getFeatures()]
>>> f
[<qgis._core.QgsFeature object at 0x0000000029F4C378>, <qgis._core.QgsFeature object at 0x0000000029F4A048>]
>>> l.addFeature(f[0])
False
Now why does addFeature()
return False
here and how can I duplicate an entry in layer_styles
table with PyQGIS?
f = f[0]
,f.setAttribute('layername', 'layer B')
and thenl.addFeature(f)
, but I fear this would fail even more so...