[Qgis-developer] pyqgis add postgres table

Bernhard Ströbl bernhard.stroebl at jena.de
Mon Feb 23 07:35:34 PST 2015


try:
uri.setDataSource('public', 'persones', None, '', 'id')

Bernhard

Am 23.02.2015 16:18, schrieb Alexandre Busquets:
> Hi,
>
> I can't add non geometry tables from postgres with pyqgis, this is my code
>
>      uri = QgsDataSourceURI()
>      uri.setConnection(bd_host, bd_port, bd_db, bd_user, bd_pass)
>      uri.setDataSource('public', 'persones', '', '', 'id')
>      taula = QgsVectorLayer(uri.uri(), 'persones', 'postgres')
>      print taula.isValid()
>
>
> What is the problem?
>
>
> Thanks
>
>



__________ Information from ESET Mail Security, version of virus signature database 11219 (20150223) __________

The message was checked by ESET Mail Security.
http://www.eset.com




More information about the Qgis-developer mailing list