[Qgis-developer] PyQGIS - Selecting Spatialite Datasource at
runtime
Germán Carrillo
carrillo.german at gmail.com
Fri Sep 10 16:18:26 EDT 2010
Hi Noli,
you could use this [1] (sorry, it's in Spanish). It uses the Sqlite3 Python
module [2].
Regards,
Germán
----------------------------
[1]
http://geotux.tuxfamily.org/index.php?option=com_myblog&task=view&id=251&Itemid=59
[2] http://docs.python.org/library/sqlite3.html
On Fri, Sep 10, 2010 at 9:49 AM, Noli Sicad <nsicad at gmail.com> wrote:
> Hi,
>
> Given, this example from PyQGIS documentation.
>
> ~~~~~~~~
> uri = QgsDataSourceURI()
> uri.setDatabase('/home/martin/test-2.3.sqlite')
> uri.setDataSource('','Towns', 'Geometry')
>
> layer = QgsVectorLayer(uri.uri(), 'Towns', 'spatialite')
> ~~~~~~~~~
>
> How do you do a runtime for the above. I want to select the table /
> layer to load. How you figure out the uri.setDataSource('',' ',
> 'Geometry') and QgsVectorLayer(uri.uri(), ' ', 'Spatialite')?
>
> ~~~~~~~~
> file = QFileDialog.getOpenFileName(self,"Open Spatialite", ".",
> "Spatialite (*.sqlite)")
> fileInfo = QFileInfo(file)
>
> uri = QgsDataSourceURI()
> uri.setDatabase(file)
> uri.setDataSource('',' ', 'Geometry')
>
> # Add the layer
> layer = QgsVectorLayer(uri.uri(), ' ', 'Spatialite')
>
> ~~~~~~~~~
>
> Noli
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
--
-----------
|\__
(:>__)(
|/
Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20100910/e5614239/attachment.html
More information about the Qgis-developer
mailing list