Skip to content

Commit

Permalink
Try-except case when pgpass does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed May 13, 2020
1 parent 737f610 commit 75b0455
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/sdssdb/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import re
import socket

import pgpasslib
import six
from pgpasslib import getpass

from sdssdb import _peewee, _sqla, config, log

Expand Down Expand Up @@ -363,7 +363,10 @@ def _conn(self, dbname, silent_on_fail=False, **params):
"""Connects to the DB and tests the connection."""

if 'password' not in params:
params['password'] = getpass(dbname=dbname, **params)
try:
params['password'] = pgpasslib.getpass(dbname=dbname, **params)
except pgpasslib.FileNotFound:
params['password'] = None

PostgresqlDatabase.init(self, dbname, **params)

Expand Down

0 comments on commit 75b0455

Please sign in to comment.