Feature request #6239
Get username and password from qgis environment
|Pull Request or Patch supplied:||No||Resolution:||invalid|
|Easy fix?:||No||Copied to github as #:||15547|
I'm trying to get this code to work:
dbConnection = QgsDataSourceURI(iface.activeLayer().dataProvider().dataSourceUri())
db = QSqlDatabase.addDatabase("QPSQL")
but the problem is that this uses the data on the .qgs file, and not the environment one.
The username and password are grabber from the .qgs project file, but we would like to get it from the environment (because we don't whant to put this sensitive data on the .qgs file).
Is there any way to get this from the environment? (From the data that the user typed when the project loads)
#5 Updated by cremat0rio - over 8 years ago
getpass.getuser() -> works, getting the username
getpass.getpass() -> blocks qgis (http://docs.python.org/library/getpass.html says it will get pass from stdin)
QgsCredentials (QgsCredentialDialog) seams to ask the user for his password, which has already been done when the project opened.
Isn't there a way to get those already gotten credentials?