Client 1—Connecting to the Server

The first step to interacting with a PostgreSQL server is to establish a connection; in this section, you'll use Tcl and Tk to build a simple graphical client that establishes a connection to a PostgreSQL server. The libpgtcl library is implemented on top of the libpq, so many of the features that you see in libpgtcl will seem familiar if you've read through Chapter 8, “The PostgreSQL C API—libpq.” To connect to a PostgreSQL server, use the pg_connect procedure. pg_connect comes in two flavors:

pg_connect -conninfo connection-string

or

pg_connect database-name
           [-host host-name]
           [-port port-number]
           [-tty tty-name]
           [-options option-string]

The second form is considered obsolete, and I've included it here only ...

Get PostgreSQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.