<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="default-style">
Dear list
</div>
<div class="default-style">
</div>
<div class="default-style">
I want to change the datasource of some layers with a qgis plugin. It is a change from gdb to postgres. I am checking the new source in a testlayer:
</div>
<div class="default-style">
</div>
<div class="default-style">
print(layer.source()) returns:
</div>
<div class="default-style">
old: //zihl/grundlagen/1_GeodatenLV95/2_Kanton_Bern/AGI/A_AV_admin/MOPUBE/data/MOPUBE.gdb|layername=MOPUBE_LIF
</div>
<div class="default-style">
</div>
<div class="default-style">
print(testlayer.source()) returns:
</div>
<div class="default-style">
dbname='be' service='be' key='id' checkPrimaryKeyUnicity='1' table="AGI-MOPUBE"."MOPUBE_LIF" (geom)
</div>
<div class="default-style">
</div>
<div class="default-style">
How can I set the datasource of layer to the one of testlayer?
</div>
<div class="default-style">
Do i need layer.setDatasource() or layer.setDataProvider() ?
</div>
<div class="default-style">
</div>
<div class="default-style">
Could anyone provide an example?
</div>
<div class="default-style">
Any help is apprecaited.
</div>
<div class="default-style">
Thanks
</div>
<div class="default-style">
Bruno
</div>
</body>
</html>