I have a function that uses a layer already styled using another function and saves it as a .gpkg
and I want to save the style in that .gpkg
:
def saving_gpkg(styled_layer):
options = QgsVectorFileWriter.SaveVectorOptions()
options.driverName = "GPKG"
QgsVectorFileWriter.writeAsVectorFormatV2(styled_layer, "nice_filename", QgsCoordinateTransformContext(), options)
styled_layer.saveStyleToDatabase("polygon", "style automatically created", True, "")
The .gpkg
is created, but if I open the created file, it doesn't have the defined style, just a random single symbol. I'm missing something?