[Qgis-developer] QGIS store, in the QGIS project, users logins and passwords from PostGis

J. Gaspar Mora Navarro gaspar.mora.navarro at gmail.com
Tue Oct 23 02:59:12 PDT 2012


Hello,

I can't find how avoid QGIS store users logins and passwords from
PostGis in the QGIS project.
If I add the PostGis layer manualy from the QGIS menu, if I disable the
store user name and store password options, works corretly, the user and
password don't are stored. But if I add the layer using pyqgis from a
plugin, the information is stored, and I dont know how avoid that.

If I use this code:

##############
	uri = qgis.core.QgsDataSourceURI()
         uri.setConnection(host, port, database, usuario, password)

         # set database schema, table name, geometry column and
optionaly subset (WHERE clause)
         nombres=nombreCompletoTabla.split(".")
         if len(nombres) < 2:
             raise Exception("Falta el nombre del esquema en el nombre
de la tabla")
         esquema=nombres[0]
         tabla=nombres[1]

         uri.setDataSource(esquema, tabla, campoGeom,
condicionSeleccion,campoGid)
         vlayer = qgis.core.QgsVectorLayer(uri.uri(), tabla, "postgres")
         if not vlayer.isValid():
             raise IOError, "Fallo al abrir la capa espacial"
         # add layer to the registry
         qgis.core.QgsMapLayerRegistry.instance().addMapLayer(vlayer)

#########

QGIS write that in the QGIS project:

             <datasource>dbname='propiedad' host=localhost port=5432
user='usuario' password='xeiraaixo' key='gid'
table="src25830"."elem_interiores" (geom) sql=id_trabajo in (select
id_trabajo from comun.trabajos where
municipio='12032;Borriana/Burriana')</datasource>


How can I avoid that from pyqgis?

Thank you for your time.





More information about the Qgis-developer mailing list