code.py
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) |