I am creating some layers in QGIS using PostgreSQL connection.
I have a python plugin doing the load of the layer in Qgis, this part of the code looks like this :
uri = QgsDataSourceURI()
db = SettingsProperties.get_db()
pg = SettingsProperties.get_postgre_settings()
uri.setConnection(db['host'], str(db['port']), project_name, pg['user'], pg['password'])
uri.setDataSource('work', table_name, str(column_geom))
layer = QgsVectorLayer(uri.uri(), tr(layer_name), "postgres")
No problem with this, but now, I would like to setup style when creating this layer, this relying on the value of some column ... etc
Actually, I am able to setup style through a .qml prepared, but I wanted to know if there is a possibility to create the style either in PostgreSQL or in the Python script in a "simple" way and then add it to the database ?
I know you can save the style with QGIS GUI. But I would like to script it.