I wish to edit and remove qgsfeatures in qgsvectorlayer. Vectorlayer contains postgis table.

QgsVectorDataProvider::capabilitiesString() returns the folowing string: Add Features, Add Attributes, Delete Attributes, Fast Access to Features at ID, Simplify Geometries, Simplify Geometries with topological validation

So it looks like I can only add new features, not edit/delete already created. Why?

3 Answers 3


You have to use the attribute table for this, where you can see all the data inside the table you´ve added. See here for a detailed introduction. At its bottom you see a marker-symbol which you may use to edit the data.

  • I have no rights to edit postgis table nor from qgis main view, nor from attribute table, nor from c++ code. It looks like the problem in postgis database rights. But i have no ideas how to solve this problem.
    – Gisman
    Oct 26, 2015 at 13:51

You could delete features if you know their ID by loading the layer into canvas from the DB Manager:

DB Manager

Then from the Python Console, you can use:

layer = qgis.utils.iface.activeLayer()
layer.dataProvider().deleteFeatures([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

Then from the DB Manager > Table, select the Run Vacuum Analyze tool to update the data table:


You should then see your list of rows updated:


Hope this helps!


Well it looks like i've found the answer to my question.

Postgres tables generated with osm2pgsql don't have a primary key. Postgis fails to edit/delete rows in such tables, but alows to add new rows.

Adding primary key to my table solved problem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.