Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool does not use passwords in .pgpass file #8

Open
nickgsc opened this issue Oct 29, 2020 · 2 comments
Open

Tool does not use passwords in .pgpass file #8

nickgsc opened this issue Oct 29, 2020 · 2 comments

Comments

@nickgsc
Copy link

nickgsc commented Oct 29, 2020

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
@gabriel-tincu
Copy link

Can you provide an example source connection string you have used please?

@nickgsc
Copy link
Author

nickgsc commented Nov 12, 2020

Sure, it's simply a connection string without the password included:
postgres://username@hostname:port/dbname?sslmode=require

This works fine with a properly configured .pgpass file when using other tools like psql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants