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

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


El 23/10/2012 8:41, Jürgen E. Fischer escribió:
> Hi J.
>
> On Tue, 23. Oct 2012 at 08:00:55 +0200, J. Gaspar Mora Navarro wrote:
>> I can't find how avoid QGIS stores users logins and passwords from
>> PostGis in the QGIS project.
>>
>> If I use this code:
>>
>>          uri = qgis.core.QgsDataSourceURI()
>>          uri.setConnection(host, port, database, usuario, password)
> Don't set username and password - otherwise they'll get saved.
> But in that case QGIS will ask interactively for a the credentials via
> QgsCredentials.  You might be able to avoid that using [1], before adding the
> layers.
>
>
> Jürgen
>
> [1] http://www.qgis.org/api/classQgsCredentials.html#a13e8e43c36c056e7ece146e985136658
>
Hello,

Thanks you for your answer,

I found the solution for my problem. Only need change the user and 
password params for "" value. QGIS ask that interactively only one time 
and loads all layers from PostGis.

         uri = qgis.core.QgsDataSourceURI()
         uri.setConnection(host, port, database, "", "")




More information about the Qgis-developer mailing list