0

I've a fresh install of Postgresql 14. I can get in with no problems on the local machine in the terminal, and remotely with pgAdmin 4.

However, I have a Python script that passes a connection string to psycopg2 and sqlalchemy. Using exactly the same credentials and config, authentication fails.

This Python script works perfectly fine when pointed at a managed Postgres instance.

The Python outputs: sqlalchemy.exc.OperationalError: (psycopg2.OperationalError)

From the Postgres logs: FATAL: 28P01: password authentication failed for user "user"

The Postgres user's password is stored in scram-sha-256. Any pointers welcome!

amg_
  • 1
  • 1
  • What does the db log file say? Does your password have any special characters that need to be URI encoded? When you connect successfully, are you also using the connection string, or are you using the exploded format? – jjanes Sep 10 '22 at 18:33
  • The db log reports the same as the Python script: password auth failed. Connecting successfully from pgAdmin is with the connection wizard, so exploded. I'll check special characters now. – amg_ Sep 10 '22 at 18:35

1 Answers1

0

Thank you very much to jjanes above, it was just a problem with special characters! I had an unhandled %.

amg_
  • 1
  • 1