[Qgis-developer] PyQGIS - Selecting Spatialite Datasource at
runtime
Noli Sicad
nsicad at gmail.com
Fri Sep 10 19:27:03 EDT 2010
Hi Germán,
Thank you.
Now it is English :-). Using Google Translate.
http://translate.google.com/translate?js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&sl=auto&tl=en&u=http%3A%2F%2Fgeotux.tuxfamily.org%2Findex.php%3Foption%3Dcom_myblog%26task%3Dview%26id%3D251%26Itemid%3D59
German, would be able to share the whole source code of the project?
Thanks again.
Regards, Noli
On 9/11/10, Germán Carrillo <carrillo.german at gmail.com> wrote:
> 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/
>
More information about the Qgis-developer
mailing list