[Qgis-developer] Custom query for the spatialite provider

Giuseppe Sucameli sucameli at faunalia.it
Thu Oct 21 17:35:27 EDT 2010


Hi devs,

a few days ago I wrote a patch to load a spatialite layer using a custom
query.
It works in the same manner as it was done for the postgres provider.

Here the ticket [1].

I know that Nov 23 starts the feature freeze, but I hope we can include it
in QGis1.6.
I did many tests and seems it works fine.

The following is a python code snippet of its usage:

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' AND t.Peoples > 10000
AND Contains(r.Geometry, t.Geometry)",
uri = QgsDataSourceURI()
uri.setDatabase('/home/brushtyler/Projects/Work/Faunalia/spatialite/test-2.3.sqlite')
uri.setDataSource('', '(%s)' % sql, 'Geometry', '', 'PK_UID')
qgis.utils.iface.addVectorLayer(uri.uri(), "Towns in RT", 'spatialite')


Cheers.

[1] https://trac.osgeo.org/qgis/ticket/3139

-- 
Giuseppe Sucameli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20101021/2f2627ea/attachment.html


More information about the Qgis-developer mailing list