pythonpostgresqlconnection-stringpsycopg3connection-pool

psycopg_pool.ConnectionPool conninfo WARNING error connecting in 'pool-1': [Errno -2] Name or service not known


with ConnectionPool(
    conninfo = app.config["POSTGRESQL_DATABASE_URI"],
    max_size = app.config["DB_MAX_CONNECTIONS"],
    kwargs = connection_kwargs,
    ) as pool:

With a connection string of postgresql://username:password@ipaddress:5432/database, I get the error:

WARNING  error connecting in 'pool-1': [Errno -2] Name or service not known

I can connect to it from psql CLI with exactly the same parameters without any problem. Note that the password contains special characters such as @ and $


Solution

  • from urllib import parse
    parse.quote("the password which contains special characters")