With no arguments, this function initializes (reinitializes if a
connection had been previously set up) a connection to the
Postgres backend. Since Postgres requires a database to be
selected, it will try to connect to the default database. The
connection may fail however for a variety of reasons, in this case
the most likely of all is because you don't have enough authority
to connect to that database. So use of this particular syntax is
discouraged.
The host argument can have the syntax "hostname"
or
"hostname:portname"
. This allows to specify the TCP/IP
port to connect to. If it is 0
or ""
, it will try
to connect to localhost, default port.
The database argument specifies the database to connect to. If
0
or ""
, it will try to connect to the specified
database.
The username and password arguments are silently ignored, since
the Postgres C API doesn't allow to connect to the server as any
user different than the user running the interface.