Navigation Menu

Skip to content

Commit

Permalink
[dbmanager] PG ignore env if service file is used
Browse files Browse the repository at this point in the history
Cherry-picked from master

Fixes #14436

Funded by Boundless
  • Loading branch information
Alessandro Pasotti committed Apr 12, 2016
1 parent 35c01f8 commit 0bde357
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/plugins/db_manager/db_plugins/postgis/connector.py
Expand Up @@ -48,11 +48,15 @@ def __init__(self, uri):
self.host = uri.host() or os.environ.get('PGHOST')
self.port = uri.port() or os.environ.get('PGPORT')

username = uri.username() or os.environ.get('PGUSER') or os.environ.get('USER')
username = uri.username() or os.environ.get('PGUSER')
password = uri.password() or os.environ.get('PGPASSWORD')

self.dbname = uri.database() or os.environ.get('PGDATABASE') or username
uri.setDatabase(self.dbname)
# Do not get db and user names from the env if service is used
if uri.service() is None:
if username is None:
username = os.environ.get('USER')
self.dbname = uri.database() or os.environ.get('PGDATABASE') or username
uri.setDatabase(self.dbname)

expandedConnInfo = self._connectionInfo()
try:
Expand Down

0 comments on commit 0bde357

Please sign in to comment.