code.py

Python Code - Samuel Ingarfield, 2014-12-09 03:33 AM

Download (311 Bytes)

 
1
from qgis.core import *
2
from qgis.utils import *
3

    
4
uri=QgsDataSourceURI()
5
uri.setDatabase('the_database.sqlite')
6
uri.setDataSource('','(SELECT id, MAX(id), geom FROM the_table)','geom','','id')
7
vlayer = QgsVectorLayer(uri.uri(), "my_table", "spatialite")
8
QgsMapLayerRegistry.instance().addMapLayer(vlayer)