The libpq library is a C language API that provides access to the PostgreSQL back end. In fact, most of the provided client tools (like psql) use this library as their connection route to the back end.
The libpq provides many functions that can control nearly every aspect of the client/server. Although an in-depth discussion of every function is outside the scope of this chapter, the two most popular functions it provides are as follows:
PQconnectdb. Connects to a database.
PQexec. Sends and executes a query to the back end.
PQconnectdb also provides the following functions:
PQreset. Resets client/server communication.
PQfinish. Closes the database connection.
PQconnectdb and PQexec are both discussed in more detail in the following sections. ...
Get PostgreSQL Essential Reference 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.