This question is somewhat involved, so please bear with me. I am updating several plugins from QGIS 2 to 3. Most of them include accessing spatialite databases and creating layers from the various tables in the databases, both with and without geometries. After making the necessary code changes to get the layers to load, I noticed that the General tab under Log Messages included the following warning for each of the layers created.
WARNING Could not load styles from [path] (Query [SELECT statement])
I discovered that saving the default style to the database as follows made the warnings disappear (saving to Local Database did not fix the issue).
Layer==>Properties==>Symbology==>Style==>Save as Default==>Datasource Database
However, this in turn produced another error and prompted this question.
THE REAL QUESTION:
The following code worked until saving the default style:
renderer = segments_layer.renderer() root_rule = renderer.rootRule() # This line fails ... rule = root_rule.children().clone()
It seems that saving the styles changed the renderer of the layer from
QgsSingleSymbolRenderer, and the latter does not have a
rootRule() attribute which is required in subsequent lines to function properly.
How can I have the best of both worlds, where I am not getting the WARNING messages and the code works as required?