I wonder if it is possible to get the user and password for a PostGIS database if they are stored in the PostGis connection information.
I get the connection information at the moment from the active layer like this:
connInfo = QgsDataSourceURI(layer.dataProvider().dataSourceUri()).connectionInfo() print connInfo dbname='test_geodata_project' host=10.0.4.111 port=5432 sslmode=disable userInfo = QgsCredentials.instance().get(connInfo, None, None) print userInfo (True, u'testuser', 'test')
But the user has to type in the user/password manually. Is there something like the
connectionInfo() but with user/password?