Postgres C API
Most database programming is done in a language like C/C++, Java or
Python.
We will discuss access from C, using the native Postgres API: libpq
I have no idea why it is libpq and not libpg.
What you need to use libpq
Whenever you use a function in C code you need:
- Header files: Declarations of the functions you will use; the API.
- A library:
- The compiled code, implementing the capabilities that you need.
- In this case: Communicate on port 5432, and the functions
needed to connect, update, and the C Postgres API.
- For standard parts of Linux, these header files and libraries are
known places, e.g. /usr/include, /usr/lib.
- Default settings of various Makefile variables are configured
to look there.
- For packages you install yourself, (e.g. Postgres), you need
to specify where to find the installed header files and libraries.
|