<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Thanks to both Jorge and Luigi,<br>
      <br>
      The queries received by postgresql are below <br>
      <br>
      The core problem seems to be that f_table_catalog is populated as
      a NULL rather than the database name.<br>
      Ironically it appears that loading would still work but it fails
      as  " f_table_catalog=NULL" is the incorrect syntax and needs to
      be " f_table_catalog  IS NULL"<br>
      <br>
      Afraid my python skills aren't well enough developed to determine
      why the database name is not being passed through to the queries.<br>
      <br>
      I attempted to register the issue as a QGIS bug, but it's not
      readily apparent how to <a href="https://hub.qgis.org/login">register</a>
      as a new user.<br>
      <br>
      Tony<br>
      <br>
      <br>
      <br>
      Saving a style<br>
      <i>2017-01-15 17:42:56 ACDT [18200-13] tonbaz@tonbaz LOG: 
        statement: SELECT COUNT(*) FROM information_schema.tables WHERE
        table_name='layer_styles'</i><i><br>
      </i><i>2017-01-15 17:42:56 ACDT [18200-14] tonbaz@tonbaz LOG: 
        statement: SELECT styleName FROM layer_styles WHERE
        f_table_catalog=NULL AND f_table_schema='public' AND
        f_table_name='g_parepg_polygons' AND f_geometry_column='geom'
        AND styleName='test01'</i><i><br>
      </i><i>2017-01-15 17:42:56 ACDT [18200-15] tonbaz@tonbaz LOG: 
        statement: INSERT INTO
layer_styles(f_table_catalog,f_table_schema,f_table_name,f_geometry_column,styleName,styleQML,styleSLD,useAsDefault,description,owner)
        VALUES
        (NULL,'public','g_parepg_polygons','geom','test01',XMLPARSE(DOCUMENT
        '<!DOCTYPE qgis PUBLIC ''<a class="moz-txt-link-freetext" href="http://mrcc.com/qgis.dtd">http://mrcc.com/qgis.dtd</a>''
        ''SYSTEM''></i><br>
      <br>
      loading a style<br>
      <i>2017-01-15 17:45:06 ACDT [18235-13] tonbaz@tonbaz LOG: 
        statement: SELECT id,styleName,description FROM layer_styles
        WHERE f_table_catalog=NULL AND f_table_schema='public' AND
        f_table_name='g_parepg_polygons' AND f_geometry_column='geom'</i><i><br>
      </i><i>2017-01-15 17:45:06 ACDT [18235-14] tonbaz@tonbaz LOG: 
        statement: SELECT id,styleName,description FROM layer_styles
        WHERE NOT (f_table_catalog=NULL AND f_table_schema='public' AND
        f_table_name='g_parepg_polygons' AND f_geometry_column='geom')
        ORDER BY update_time DESC</i><i><br>
      </i><br>
      <br>
      On 13/01/17 20:46, Jorge Gustavo Rocha wrote:<br>
    </div>
    <blockquote class=" cite"
      id="mid_81016e90_fe23_f36e_5df3_e065b31588c7_di_uminho_pt"
      cite="mid:81016e90-fe23-f36e-5df3-e065b31588c7@di.uminho.pt"
      type="cite">
      <pre wrap="">Hi Tony,

If you can see the styles in later_styles table, you can try to run the
two queries executed by QGIS to populate the dialog. The first is for
the styles associated with the layer. The later is for all other styles.

-- replace 'publica' with your database
-- replace 'pdm11_c_geral' with your schema
-- replace 'ran' with your table name
-- replace 'the_geom' with your geometry column

SELECT id,styleName,description
FROM layer_styles
WHERE f_table_catalog='publica' AND f_table_schema='pdm11_c_geral' AND
f_table_name='ran' AND f_geometry_column='the_geom'

SELECT id,styleName,description
FROM layer_styles
WHERE NOT (f_table_catalog='publica' AND f_table_schema='pdm11_c_geral'
AND f_table_name='ran' AND f_geometry_column='the_geom')
ORDER BY update_time DESC

Did these queries returned the any styles?

You can log your own Postgresql queries to check what is going on.

Regards,

Jorge Gustavo

Às 02:23 de 13-01-2017, Tony Bazeley escreveu:
</pre>
      <blockquote class=" cite" id="Cite_3551623" type="cite">
        <pre wrap="">Hi,

I'm having some trouble attempting to work with styles in postgresql.

I can successfully save a style to the database - table layer_styles is
created and populated.
But attempting to load brings up the 'Load Style from database dialog'
with messages "No styles found in database'

Am using QGIS 2.18.2 with postgresql 9.6 and postgis 2.3

Would appreciate any thoughts on how to progress.

Thanks
Tony



_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>

</pre>
      </blockquote>
      <pre wrap="">J. Gustavo
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>