[QGIS-Developer] setDataSourceUri() not working

Andrea Giudiceandrea andreaerdna at libero.it
Thu Dec 8 10:42:12 PST 2022


> *Raymond Nijssen*
> /Wed Dec 7 07:39:50 PST 2022/
> ------------------------------------------------------------------------
> I'm trying to change the dataSourceUri of an existing layer

Hi Raymond,
AFAIK you need to use setDataSource [1] directly on the layer an not 
setDataSourceUri on the data provider.

E.g.:

layer.setDataSource(new_ds, layer_name, 'ogr')


Best regards.

Andrea

[1] 
https://qgis.org/pyqgis/master/core/QgsMapLayer.html#qgis.core.QgsMapLayer.setDataSource
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20221208/b708add6/attachment.htm>


More information about the QGIS-Developer mailing list