Skip to content

Tool does not use passwords in .pgpass file #8

@nickgsc

Description

@nickgsc

Standard operating procedure for postgres commandline tools that leverage libpq (such as psql, pg_dump, etc) is that they will look for a password in the .pgpass file in the home directory of the running user. This allows for interacting with databases without having to supply a password in the clear on the commandline. https://www.postgresql.org/docs/12/libpq-pgpass.html

I attempted to run the tool without supplying the password expecting it would leverage .pgpass, but that did not work:

2020-10-29 16:09:39,632	PGMigrate	ERROR	fe_sendauth: no password supplied

Traceback (most recent call last):
  File "/Users/nickwilson/git/aiven-db-migrate/aiven_db_migrate/migrate/pgmigrate.py", line 947, in validate
    if self.source.version > self.target.version:
  File "/Users/nickwilson/git/aiven-db-migrate/aiven_db_migrate/migrate/pgmigrate.py", line 161, in version
    self._version = LooseVersion(self.params["server_version"])
  File "/Users/nickwilson/git/aiven-db-migrate/aiven_db_migrate/migrate/pgmigrate.py", line 154, in params
    params = self.c("SHOW ALL")
  File "/Users/nickwilson/git/aiven-db-migrate/aiven_db_migrate/migrate/pgmigrate.py", line 139, in c
    with self._cursor(dbname=dbname) as cur:
  File "/usr/local/Cellar/[email protected]/3.8.6_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/Users/nickwilson/git/aiven-db-migrate/aiven_db_migrate/migrate/pgmigrate.py", line 121, in _cursor
    conn = psycopg2.connect(**conn_info)
  File "/usr/local/lib/python3.8/site-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
  File "/usr/local/lib/python3.8/site-packages/psycopg2/extras.py", line 778, in wait_select
    state = conn.poll()
psycopg2.OperationalError: fe_sendauth: no password supplied

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions