libpq
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. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access