Hi devs, <br><br>a few days ago I wrote a patch to load a spatialite layer using a custom query. <br>It works in the same manner as it was done for the postgres provider.<br><span style="font-family: comic sans ms,sans-serif;"></span><br>
Here the ticket [1].<br><br>I know that Nov 23 starts the feature freeze, but I hope we can include it in QGis1.6. <br>I did many tests and seems it works fine. <br><br>The following is a python code snippet of its usage:<br>
<br><span style="font-family: comic sans ms,sans-serif;">sql = "SELECT t.PK_UID, t.Name, (t.Peoples/1000) AS KPeoples, t.Geometry FROM Towns AS t, Regions AS r WHERE r.Name =
'TOSCANA' </span><span style="font-family: comic sans ms,sans-serif;">AND t.Peoples > 10000 AND Contains(r.Geometry,
t.Geometry)",</span><br style="font-family: comic sans ms,sans-serif;"><span style="font-family: comic sans ms,sans-serif;">uri = QgsDataSourceURI() </span><br style="font-family: comic sans ms,sans-serif;"><span style="font-family: comic sans ms,sans-serif;">uri.setDatabase('/home/brushtyler/Projects/Work/Faunalia/spatialite/test-2.3.sqlite')</span><br style="font-family: comic sans ms,sans-serif;">
<span style="font-family: comic sans ms,sans-serif;">uri.setDataSource('', '(%s)' % sql, 'Geometry', '', 'PK_UID')</span><br style="font-family: comic sans ms,sans-serif;"><span style="font-family: comic sans ms,sans-serif;">qgis.utils.iface.addVectorLayer(uri.uri(), "Towns in RT", 'spatialite')</span><br style="font-family: comic sans ms,sans-serif;">
<br><br>Cheers.<br clear="all"><br>[1] <a href="https://trac.osgeo.org/qgis/ticket/3139" target="_blank">https://trac.osgeo.org/qgis/ticket/3139</a><br><br>-- <br>Giuseppe Sucameli<br><br>