TransWikia.com

How to load the layer style from Postgresql with Python?

Geographic Information Systems Asked on February 1, 2021

I would like to write a python macro that upon opening my QGIS project file will reload the default style for each layer from the postgres ‘layer_style’ table. I have had a look at the documentation and can only work out how this is done from a sqlite db or .qml file.

Any pointers would be appreciated.

One Answer

Resurrecting the topic with QGIS 3.0 :). Looking at the QgsVectorLayer API documentation instead of QgsMapLayer API, you have the answer. You can use method saveStyleToDatabase

There are related recipes to manipulate styles in PostgreSQL database from QGIS Python tests including saveStyleToDatabase case at https://github.com/qgis/QGIS/blob/master/tests/src/python/test_provider_postgres.py#L1553

Answered by ThomasG77 on February 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP