[Qgis-developer] Load a Spatialite layer using python bindings

Marcelo Reyes reyesmarcelo at gmail.com
Sat Mar 27 11:59:34 EDT 2010


Thanks a lot Martin, it works!

Bye
Marcelo

On Sat, Mar 27, 2010 at 10:26 AM, Martin Dobias <wonder.sk at gmail.com> wrote:

> On Sat, Mar 27, 2010 at 6:23 AM, Marcelo Reyes <reyesmarcelo at gmail.com>
> wrote:
> >
> > Hello,
> >
> > I'm trying to load a vector layer from a spatialite table. It is easy to
> do
> > it in qgis using the tool bar option, but I want to do it programatically
> > using the python bindings. This is because I'm developing a small stand
> > alone application.
> >
> > Can any one show me an example of how to to this? I've found code with
> > Postgis, but none with spatialite.
>
> uri = QgsDataSourceURI()
> uri.setDatabase('/home/martin/test-2.3.sqlite')
> uri.setDataSource('','Towns', 'Geometry')
>
> v=QgsVectorLayer(uri.uri(), 'Towns', 'spatialite')
>
> (don't forget to check v.isValid() to see whether the vector layer got
> loaded correctly)
>
> Bye
> Martin
>



-- 
Marcelo Reyes
Edif. Alborada Of. 605
Tel. 2201034
Cel. 72501267
La Paz Bolivia.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20100327/eb7587e0/attachment.html


More information about the Qgis-developer mailing list