def extract_db_conn_args(args):
    """Returns subset of ``args`` of args used for db connection

    :param args: either a `dict` or a namespace (e.g. argparse.Namespace)

    """
    args = vars(args) if not isinstance(args, dict) else args
    return dict(database=args.get('pg_database'), host=args.get('pg_host'),
        password=args.get('pg_password'), user=args.get('pg_user'))
