canvas = qgis.utils.iface.mapCanvas() <br>
layer = canvas.currentLayer()<br>
print(layer.name())<br>
options = QgsVectorFileWriter.SaveVectorOptions()<br>
options.actionOnExistingFile = QgsVectorFileWriter.CreateOrOverwriteLayer

#options.layerName = "_".join(layer.name().split(' '))<br>
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, "C:/Users/ilyasse2.0/Documents/SQRLAND/hh.gpkg", options)<br>
print(writer)<br>
i get this error  : 
# (2, 'Opening of data source in update mode failed (OGR error: )')
this layer is created by :  <br>
layer = QgsVectorLayer("Point", 'layerName', "memory")