Text Size: Normal / Large

pg_connect

Name

pg_connect -- open a connection to the server

Synopsis

pg_connect -conninfo connectOptions
pg_connect dbName ?-host hostName? ?-port portNumber? ?-tty tty? ?-options serverOptions?

Description

pg_connect opens a connection to the PostgreSQL server.

Two syntaxes are available. In the older one, each possible option has a separate option switch in the pg_connect command. In the newer form, a single option string is supplied that can contain multiple option values. pg_conndefaults can be used to retrieve information about the available options in the newer syntax.

Arguments

New style

connectOptions

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 libpq function PQconnectdb.

Old style

dbName

The name of the database to connect to.

-host hostName

The host name of the database server to connect to.

-port portNumber

The TCP port number of the database server to connect to.

-tty tty

A file or TTY for optional debug output from the server.

-options serverOptions

Additional configuration options to pass to the server.

Return Value

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


User Comments


Michael Schlenker <schlenk AT uni-oldenburg.de>
06 Aug 2004 12:25:59

The actual connection options syntax is a bit confusing, as it isn\'t stated clearly how it is done. Naively i would have expected a typical Tcl name value pair list, not this string with = in between.

What i found working was:

set handle [pg_connect -conninfo {host = localhost password = foo user = bar dbname test}]

Add Comment

Please use this form to add your own comments regarding your experience with particular features of PostgreSQL, clarifications of the documentation, or hints for other users. Please note, this is not a support forum, and your IP address will be logged. If you have a question or need help, please see the faq, try a mailing list, or join us on IRC. Note that submissions containing URLs or other keywords commonly found in 'spam' comments may be silently discarded. Please contact the webmaster if you think this is happening to you in error.

In order to submit a comment, you must have a community account.

* Comment
 

* denotes required field

Privacy Policy | Project hosted by hub.org | Designed by tinysofa
Copyright © 1996 – 2007 PostgreSQL Global Development Group