select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Unsupported versions: 7.0 / 6.5 / 6.4
Historical version. PostgreSQL 6.4 reached end of support in October 2003. See the current manual for supported releases.

pg_connect

Name

pg_connect — opens a connection to the backend server
pg_connect -conninfo connectOptions
pg_connect dbName [-host hostName]
  [-port portNumber] [-tty pqtty]
  [-options optionalBackendArgs]

Inputs (new style)

connectOptions

A string of connection options, each written in the form keyword = value.

Inputs (old style)

dbName

Specifies a valid database name.

[-host hostName]

Specifies the domain name of the backend server for dbName.

[-port portNumber]

Specifies the IP port number of the backend server for dbName.

[-tty pqtty]

Specifies file or tty for optional debug output from backend.

[-options optionalBackendArgs]

Specifies options for the backend server for dbName.

Outputs

dbHandle

If successful, a handle for a database connection is returned. Handles start with the prefix "pgsql".

Description

pg_connect opens a connection to the Postgres backend.

Two syntaxes are available. In the older one, each possible option has a separate option switch in the pg_connect statement. In the newer form, a single option string is supplied that can contain multiple option values. See pg_conndefaults for info about the available options in the newer syntax.

Usage

XXX thomas 1997-12-24

Report a documentation issue

Read the upstream documentation. For corrections, first check the current manual.