2

I wrote a script (for QGIS 3) that saves styles for all visible vector layers in QML and SLD files:

import processing
self=qgis.utils
layers = self.iface.mapCanvas().layers()

for layer in layers:
    layerType = layer.type()
    if layerType == QgsMapLayer.VectorLayer:
        name = layer.name()
        pathqml = 'C:/Style/QML/'+str(name)+'.qml'  
        pathsld = 'C:/Style/SLD/'+str(name)+'.sld'  
        layer.saveNamedStyle(pathqml)
        layer.saveSldStyle(pathsld)

How can I do this for the layers from SQLite, PostgreSQL/PostGIS ?

  • 1
    Are the sqlite and postgis layers not loaded into your Q project? Are you wanting to save those layer styles to a folder or to a database? – artwork21 Mar 23 '18 at 13:12
0

To save the style into a database use:

layer.saveStyleToDatabase("NameOfStyle","Description",True,"uiFileContent")
  • here database mean postgres , what if there are multiple database connected ? – Abhijit Gujar Jun 28 '18 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.