.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $
.TH "PG_CONNECT" "" "2007-09-16" "" "PostgreSQL 7.4.18 Documentation"
.SH NAME
pg_connect \- open a connection to the server

.SH SYNOPSIS
.sp
.nf
pg_connect -conninfo \fIconnectOptions\fR
pg_connect \fIdbName\fR [-host \fIhostName\fR] [-port \fIportNumber\fR] [-tty \fItty\fR] [-options \fIserverOptions\fR]
.sp
.fi
.SH "DESCRIPTION"
.PP
\fBpg_connect\fR opens a connection to the
PostgreSQL server.
.PP
Two syntaxes are available. In the older one, each possible option
has a separate option switch in the \fBpg_connect\fR
command. In the newer form, a single option string is supplied
that can contain multiple option values.
\fBpg_conndefaults\fR can be used to retrieve
information about the available options in the newer syntax.
.SH "ARGUMENTS"
"NEW STYLE"
.TP
\fB\fIconnectOptions\fB\fR
A string of connection options, each written in the form
keyword = value. A list of valid options can be
found in the description of the \fBlibpq\fR function
\fBPQconnectdb\fR.
.PP
"OLD STYLE"
.TP
\fB\fIdbName\fB\fR
The name of the database to connect to.
.TP
\fB-host \fIhostName\fB\fR
The host name of the database server to connect to.
.TP
\fB-port \fIportNumber\fB\fR
The TCP port number of the database server to connect to.
.TP
\fB-tty \fItty\fB\fR
A file or TTY for optional debug output from
the server.
.TP
\fB-options \fIserverOptions\fB\fR
Additional configuration options to pass to the server.
.SH "RETURN VALUE"
.PP
If successful, a handle for a database connection is returned.
Handles start with the prefix pgsql.
