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 ?