[Qgis-developer] Re: Custom query for the spatialite provider

Giuseppe Sucameli sucameli at faunalia.it
Tue Oct 26 07:02:01 EDT 2010


Hi all,
this morning Sandro Furieri applied my patch and now it's in trunk. See [1].
Cheers.

[1] https://trac.osgeo.org/qgis/changeset/14435

On Thu, Oct 21, 2010 at 11:35 PM, Giuseppe Sucameli <sucameli at faunalia.it>wrote:

> 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
>
>


-- 
Giuseppe Sucameli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20101026/5cfb731f/attachment.html


More information about the Qgis-developer mailing list