Hi Roberto, I had the same problem and found the solution here : https://gis.stackexchange.com/questions/318635/getting-active-postgresql-connection-username-when-stored-through-authentication/343182#343182 <https://gis.stackexchange.com/questions/318635/getting-active-postgresql-connection-username-when-stored-through-authentication/343182#343182>
HTH, Didier > Le 29 avr. 2020 à 20:50, Poltini Roberto <[email protected]> a > écrit : > > Hi All, > is it possible to have the postgres connection used by a vector layer > using python with qgis 3 ? > In qgis 2 I read the layer connection properties where I found login and > password. > A simple example to create a postgres connection used by a vector layer: > import psycopg2 > conn = psycopg2.connect(layer.dataProvider().dataSourceUri()) > > Now in layer.dataProvider().dataSourceUri() I find authConfigId property > instead of login and password but I don’t know how to use it. > This is because the new authorization system in qgis which permits to avoid > to write login and password in the qgis project file. > > Thank you for help > > Roberto Poltini > > Per essere informati sulle novità del Gruppo Iren, vi invitiamo a registrarvi > alla nostra mailing list, all’indirizzo "http://www.gruppoiren.it/" > <http://www.gruppoiren.it/> . > > È possibile, inoltre, avanzare nuove idee e progetti per il territorio e > seguire quelli già attivi nei Comitati Territoriali del Gruppo Iren, > consultando "http://www.Irencollabora.it" <http://www.irencollabora.it/> > > You can also suggest new ideas and initiatives for the territory and view > those already active in the Iren Group Territorial Committees > "http://www.Irencollabora.it" <http://www.irencollabora.it/> > > Le informazioni contenute nella presente comunicazione e i relativi allegati > possono essere riservate e sono, comunque, destinate esclusivamente alle > persone o alla Società sopraindicati. La diffusione, distribuzione e/o > copiatura del documento trasmesso da parte di qualsiasi soggetto diverso dal > destinatario è proibita, sia ai sensi dell’art. 616 c.p. , che ai sensi del > D.Lgs. n. 196/2003. Se avete ricevuto questo messaggio per errore, vi > preghiamo di distruggerlo e di informare immediatamente il mittente. > > > _______________________________________________ > QGIS-Developer mailing list > [email protected] <mailto:[email protected]> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > <https://lists.osgeo.org/mailman/listinfo/qgis-developer> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer > <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
_______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
