Skip to content

Commit

Permalink
add env lookup for AADC_DB username and pass
Browse files Browse the repository at this point in the history
  • Loading branch information
emirkmo committed Feb 8, 2023
1 parent c86499a commit 996a992
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions flows/aadc_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
.. codeauthor:: Rasmus Handberg <rasmush@phys.au.dk>
"""
import getpass
import os

import psycopg2 as psql
from psycopg2.extras import DictCursor
import getpass
from tendrils.utils import load_config


Expand Down Expand Up @@ -41,15 +42,15 @@ def __init__(self, username=None, password=None):
config = load_config()

if username is None:
username = config.get('database', 'username', fallback=None)
username = config.get('database', 'username', fallback=os.environ.get("AUDBUsername", None))
if username is None:
default_username = getpass.getuser()
username = input('Username [%s]: ' % default_username)
if username == '':
username = default_username

if password is None:
password = config.get('database', 'password', fallback=None)
password = config.get('database', 'password', fallback=os.environ.get("AUDBPassword", None))
if password is None:
password = getpass.getpass('Password: ')

Expand Down

0 comments on commit 996a992

Please sign in to comment.