The GDAL export o postgreSQL tools in processing allows you to append features to an existing layer. Disable the overwrite option, and enable the append option.
https://docs.qgis.org/3.10/en/docs/user_manual/processing_algs/gdal/vectormiscellaneous.html#export-to-postgresql-available-connections . If needed in a script, you can call that algorithm too. No need to reinvent anything. Best regards, Alexandre Neto A quarta, 13/05/2020, 15:06, Germán Carrillo <[email protected]> escreveu: > Hi Luis, > > if you are fine with a plugin solution, then there is one called "Append > Features to Layer" [1] that adds a new algorithm to QGIS Processing. > > If you run it once via Processing Toolbox, then in the Processing History > you'll get the Python command, which you could use in your code to append > features to layers. > > > BTW, QGIS Processing will come with an append features to existing layer > out-of-the-box. It's planned for QGIS 3.14. See it in action [2]. > > > Regards, > > Germán > ----------- > [1] https://github.com/gacarrillor/AppendFeaturesToLayer/ > [2] https://github.com/qgis/QGIS/pull/35641 > > El mié., 13 may. 2020 a las 6:25, Jorge Gustavo Rocha (<[email protected]>) > escribió: > >> Hola Luís, >> >> The options are quite simple. You can see them in this SO question: >> >> https://gis.stackexchange.com/questions/87404/how-to-write-a-new-layer-to-postgresql-from-qgis-plugin/360270#360270 >> >> You should create a temporary layer with the original one, plus the >> features you want to append. Then you write it to the database. >> >> Does it help? >> >> Regards, >> >> Jorge Gustavo >> >> On 13/05/20 11:57, Luís Miguel Royo Pérez wrote: >> > Hi all, >> > I'm seeking a way to append features to a layer when exporting into a >> > PostGIS layer. >> > >> > For now I'm using the tool QgsVectorLayerExporter. >> > >> > I'm doing something like this >> > >> > QgsVectorLayerExporter(uri, "postgres", fields, layer.wkbType(), >> > utils().crs, overwrite,{}).addFeatures([feat for feat in >> > layer.getFeatures()]) >> > >> > Inside the curly brackets I know I can place the options, but I can't >> > find where are these options documented. Or wether these options can >> > help me in my task of append features to a QGIS layer. >> > >> > Can anyone point me in the right direction in this task of appending >> > features? >> > >> > Kind regards. >> > -- >> > Luís Miguel Royo Pérez. >> > Analista-Programador GIS >> > C/ Antic Regne de Valencia nº 4. Manises (Valencia) >> > Teléfono:+34 679846103 >> > webs: >> > inisig.com <http://inisig.com> >> > geofibra.com <https://geofibra.com> >> > >> > >> > >> > _______________________________________________ >> > QGIS-Developer mailing list >> > [email protected] >> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> > >> >> J. Gustavo >> -- >> Jorge Gustavo Rocha >> Departamento de Informática >> Universidade do Minho >> 4710-057 Braga >> Gabinete 3.29 (Piso 3) >> Tel: +351 253604480 >> Fax: +351 253604471 >> Móvel: +351 910333888 >> skype: nabocudnosor >> _______________________________________________ >> QGIS-Developer mailing list >> [email protected] >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer > > > > -- > ----------- > |\__ > (:>__)( > |/ > Soluciones Geoinformáticas Libres > http://geotux.tuxfamily.org/ > https://twitter.com/GeoTux2 <http://twitter.com/GeoTux2> > > <http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo> > _______________________________________________ > QGIS-Developer mailing list > [email protected] > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
