Chapter 5. libpgeasy - Simplified libpq C Library

pgeasy (libpgeasy) is a library that consists of a simplified set of C functions that encapsulate the functionality of libpq.

The pgeasy interface can be found in src/interfaces/libpgeasy. Frontend programs that use libpgeasy must include the header file libpgeasy.h and must also link with the libpgeasy library (by using the -lpgeasy linker option).

Database Connection Functions

This section describes the routines in the libpgeasy library that are used to open and close a connection to a Red Hat Database backend server.

connectdb()

connectdb makes a new connection to the database server.

PGconn *connectdb (char *comminfo);

This routine opens a new database connection using the parameters taken from the string comminfo. The return value is a pointer to an abstract structure representing the connection to the backend, which becomes the "current connection". This routine encapsulates the PQconnectdb libpq function. Information regarding recognized option parameters can be found under the PQconnectdb section of libpq.

disconnectdb()

disconnectdb closes the connection to the database server.

void disconnectdb ();

This routine closes the connection to the database backend and frees storage allocated to the connection object. disconnectdb encapsulates the PGfinish libpq function.