Database Reference
In-Depth Information
Communicating with
PostgreSQL Using LibPQ
The libpq library is a PostgreSQL client library to communicate with the
PostgreSQL server. The purpose of this chapter is to write the C program to connect
to the PostgreSQL server and execute queries in the C programming language. In
this chapter, we will explore communication with PostgreSQL using libpq , which
includes learning about all the library functions and their utilization with suficient C
code examples. We will also discuss the blocking and nonblocking behavior of
libpq functions.
Connecting and disconnecting to
PostgreSQL
The libpq library provides multiple functions and mechanisms to connect to
the PostgreSQL server. We will discuss each and every function that is involved
in establishing a connection to the backend. An application can have multiple
connections with the PostgreSQL database, but needs to maintain the PGconn pointer
for each and every connection. The PGconn pointer is a connection object and a
function used to establish a connection. It returns the pointer that the application
needs to store and use for subsequent functions to query the database. This object
must be closed when the connection to the server is no longer needed because the
code must release resources that the PostgreSQL runtime allocates.
Search WWH ::




Custom Search