wiki:WikiStart

Version 87 (modified by jtv, 11 years ago) (diff)

--

Welcome!

libpqxx is the official C++ client API for PostgreSQL, the enterprise-strength open-source database software. (If "PostgreSQL" is too verbose, call it by its shorter name, postgres).

If you are writing software in C++ that needs to access databases managed by postgres—on just about any platform—then libpqxx is the library you use. The source code is available from here, although in most cases you'd normally work with pre-built binary packages provided by a package maintainer for your specific platform, and distributed through your normal package management infrastructure.

News

2008-06-18 libpqxx in OpenSolaris

Bjørn Munch informs us that libpqxx is now included in the PostgreSQL packages for OpenSolaris.

2008-04-29 Documentation snapshots

The online documentation directory now also contains the latest documentation snapshot. It's regenerated daily from the development tree.

2008-04-28 Testing for gcc 4.3

There were still a few warnings when building with g++ 4.3. They've been fixed, and we run daily tests against this compiler.

2008-04-17 Getting ready for 3.0

At last, 3.0 is nigh! The work holding up this release was the much-needed rewrite of the cursor API. To bring you the bad news first: the bulk of the cursor APIs has been ripped out—and the good news: it's been replaced with something simpler and more reliable. You no longer need worry about moving cursors around. A new class, stateless_cursor just lets you request rows by number, as in "cur.retrieve(0, 100)" (or "cur.retrieve(99, -1)" to fetch them backwards). Doing it this way was not just more user-friendly than what we tried to do before, but actually easier as well.

Check out the daily 3.0 development snapshots and latest NEWS file.

In other good news, Kirit Sælensminde has been working on improving Windows support for 3.0.

2008-04-07 Site has moved!

We've had to transplant pqxx.org to a new server. Hopefully things will work better overall, but there will be some teething problems.

Known problems with 2.6.9

We have some known problems in 2.6.9. If you run into these, implement the workarounds listed here or try the latest development snapshot.

  • "Visibility" errors while building with Red Hat-derived gcc: see bug #83. Building with some gcc versions will give you "-fvisibility" errors.
  • Spaces in Windows directory paths: see bug #105. The path to the PostgreSQL source should not contain any spaces.
  • lib directory not created in Visual C++. Workaround: "mkdir lib" in the source tree before building.
  • internal::disable_noticer not found in Visual C++: see bugs #106 and #122. Replace "internal::disable_noticer" with plain "disable_noticer" in three source files:
    1. include/pqxx/trigger.hxx (line 70)
    2. src/tablereader.cxx (line 49)
    3. src/tablewriter.cxx (line 41)

Finding Everything

Where What
Sales Pitch Why this library should interest you
Using This Site The various services offered by this development site
Download Page Source archives (no binaries; those depend on your individual platform)
FAQ Frequently Asked Questions, and their answers
Online Documentation Wiki and copies of packaged documentation
Packagers Page Information for maintainers of libpqxx packages
Bug Tracker Known bugs and requests (as in View Tickets option in top button bar)
Bugs by Milestone Bugs and feature requests, but ordered by milestone
Reporting Bugs How to report a problem or request a new feature
Mailing Lists libpqxx-general and libpqxx-announce (hosted on pgFoundry site)
Other Projects Other open-source development projects hosted here
libpqxx Elsewhere Sites where libpqxx is registered as a project
Author and Contributors Who made all this?

For issues not suitable for the mailing list or bug tickets, contact the author at jtv<img src="/boilerplate/atsgn.txt" alt="<img src="/boilerplate/atsgn.txt" alt="@" />" />xs4all.nl.

Also, you may want to have a look at the other open source projects hosted on this site.

Technical Overview

This library works on top of the C-level API library, libpq. You will need libpq in order to use libpqxx.

The first thing you're likely to notice in programming with libpqxx is that unlike other libraries, it revolves entirely around transactions. Transactions are a central concept in database management systems, but they are widely underappreciated among application developers. Another well-known open source database system, MySQL, never even got around to implementing them at all in their own engine, relying on a third-party replacement engine (now owned by Oracle) to provide this functionality instead.

It may sometimes be possible to build limited applications reliably without serious use of transactions. More usually, however, applications are designed without transactions simply because the developers aren't aware of the risks they are taking, and any data loss is rare or small enough not to be noticed. That kind of design was not considered acceptable for libpqxx.

With conventional database APIs, you issue commands and queries to a database session or connection, and optionally create the occasional transaction. In libpqxx you start a transaction inside the connection first, do your SQL work using that transaction, then commit the transaction when it's complete. There are several types of transactions with various "quality of service" properties; if you don't really want to use transactions at all, one of the available transaction types is called nontransaction. This transaction type provides classic, nontransactional behaviour.

Every command or query issues a result object, which is really a smart pointer so it can be copied around without incurring much cost in terms of performance. No need to write special code to check these for success; error conditions are converted to regular C++ exceptions. Result objects can be kept around for as long as they are needed, completely separate from the connections and transactions that originated them.


Ohloh Metrics GTF Contributor