wiki:WikiStart

Version 4 (modified by jtv, 13 years ago) (diff)

--

Welcome to the New Site

This project is just in the process of moving to this new site, from its old location at http://gborg.postgresql.org/project/libpqxx/ so don't be surprised if some things are still missing. See UsingThisSite for more details on various ways to access the source code etc.

libpqxx

libpqxx is the official C++ API for writing client programs that talk to the PostgreSQL database management system.

I hope you will find libpqxx flexible but easy to use. Not everything about it is easy, but at least there is a tendency to stick to the kinds of complexity that you are used to as a C++ programmer. Query results do not have their own "get next row" interfaces and so on; instead, they provide iterator classes that let you treat the result as a standard C++ container, just like the ones defined by the STL. Streams are also supported where it makes sense, and fields can be read into variables using conversion functions that are implemented as templates.

Also, simple libpqxx programs tend to be less complex than equivalent Java code while having more flexibility.

Many similar libraries have preceded libpqxx and perhaps many will follow. Below are some reasons why I believe libpqxx is worth your while.

  1. Language conformance. It tries to make sensible use of modern C++ features such as templates, standard exceptions, and various kinds of iterators to integrate more comfortably with the language. Where possible, libpqxx blends in with the standard library and the STL in particular.
  2. Structure. It also tries to make it easier for you to write robust, correct code that deals elegantly with various kinds of error conditions. This helps the library detect many problems at compile time instead of at runtime, or during a normal test instead of just in rare corner cases.
  3. Power. Built-in features such as automatic connection restoration and transaction management free you from the low-level chores that tend to take up too much time and go wrong just when you need them most.
  4. Flexibility. Despite the above, this is not an application framework. You won't be forced to squeeze your code into a poorly matched, poorly documented event loop. There are no home-grown string or exception classes. The library lives in its own namespace and completely hides all symbols of the underlying C API library, so it's less likely to clash with other libraries.
  5. Generic programming. Object-orientation is a fine thing, but let's not get obsessed. Functions are used where they make more sense than classes. Inheritance is used internally, but you are not expected to derive your own classes from libpqxx classes except in one or two specific and useful design patterns. Even then, your own code will be isolated in a well-understood environment.

If your impression is that libpqxx is nothing special, that everything about it is obvious or unsurprising, then that means it does its job.