A string containing database connection parameters

A conninfo string is one method of supplying PostgreSQL connection parameters to libpq and some applications based on libpq, such as psql. It consists either of parameters specified in a "keyword=value" format separated by spaces, e.g. "host=localhost dbname=testdb", or an URI-style string (as defined by RFC 3986), e.g. "postgresql://localhost/testdb".

libpq functions

libpq provides the following function for handling conninfo strings:

  • PQconninfoParse()

Change history


Connect to PostgreSQL with a conninfo string:

$ psql "host=localhost dbname=testdb"
psql (13.1)
Type "help" for help.


Note the string can also be provided with the -d/--dbname option, e.g.:

$ psql -d "host=localhost dbname=testdb"
psql (13.1)
Type "help" for help.

  • conninfo - an extension providing functions for manipulating conninfo strings


Database connections, PostgreSQL concept