I have problems to save a vectorlayer at QGIS 3.0 with his original name in a GeoPackage.
canvas = qgis.utils.iface.mapCanvas() layer = canvas.currentLayer() writer = QgsVectorFileWriter.writeAsVectorFormat(layer, "V:/test_layer/test_gpkg", 'utf-8', layer.crs(), "GPKG")
With this code I create a Geopackage with the selected vectorlayer in it. The only Problem is that the saved vectorlayer has the same name as the GeoPackage.
Can somebody help me to save the vectorlayer in a different name than the GeoPackage and maybe how to add other vectorlayers?