Support for connections/connstrings that don't require passwords
Is your feature request related to a problem? Please describe.
When using typical connection strings, you can exclude the password part as postgres (by default, on many machines) authenticates the connection via PEER authentication method. This requires no password nor username. Otherwise, there are also settings (in pg_hba.conf) that allows all users to connect to any role without password.
But - as far as I can tell - pgx only authenticates with password-provided methods. Any attempt to use a connstring without a password you get:
failed to connect to `host=localhost user=<user> database=<database>`: failed SASL auth (FATAL: password authentication failed for user "<user>" (SQLSTATE 28P01))
Describe the solution you'd like Tthe connstrings that exclude passwords should be possible on postgres instances where passwords are not needed.
peer authentication only works over a local Unix socket not TCP. You are connecting to localhost which means using TCP. Use a Unix socket (e.g. /tmp/ or /var/run/postgresql) as your host and it should work fine.
If your PostgreSQL socket is in one of the normal places, pgx will default to that if no host is given. And pgx will use the OS user name as user if not otherwise provided. So you conn string might work with just database=<database>.