wiki:WikiStart

Version 123 (modified by jtv, 9 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

2010-12-03: Changing a table's primary key in-place

I've been working on a way to change a table's primary key without having to re-index it. This can be useful for large tables where you can only afford to create indexes concurrently (which ADD CONSTRAINT does not support).

2010-11-06: Dropping support for postgres 7.3

We enjoyed supporting the obsolete 7.x libpq versions for as long as we could in libpqxx, but it's come to a point where that is no longer possible.

The reason is a combination of changes in the escaping format for binary strings. Even in the current development versions with its various fixes for this situation, we no longer see a way to keep a 7.3 libpq compatible with the new 9.1 alpha-release backends. We'll try to keep libpq 7.4 supported for a little while longer, but may have to give up on that too.

Unfortunately there are also no existing libpqxx releases that will make this work. Using a 7.4 libpq with a 9.x backend should still work, but you may need a development version of libpqxx. Run the test suite against your particular configuration to be sure.

2010-10-26: Performance Tips page

I presented some basic query optimization tips at Barcamp this weekend. To my horror, most of my audience had never heard of "EXPLAIN ANALYZE" and such. So much for my plan to zoom past the basics and get straight to some hard queries!

But since there seems to be an interest, we now have a PerformanceTips page to help users learn how to solve their database performance problems.

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
Consulting? Where can I get professional development help?
Bug Tracker Known bugs and requests (as in View Tickets option in top button bar)
Reporting Bugs How to report a problem or request a new feature
Mailing Lists Hosted on pgFoundry site
Database Notes Notes and tips about postgres
Performance Tips Figure out and solve performance problems
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 as jtv at 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 need to know is that libpqxx revolves around transactions. Transactions are a central concept in database management systems, but they are widely underappreciated among application developers. In libpqxx, they're fundamental.

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 with a connection, but you do all your SQL work in transactions that you open in your connection. You commit each transaction when it's complete; if you don't, all changes made inside the transaction get rolled back.

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 basic nontransactional behaviour.

Every command or query returns a result. All result data is fetched immediately. The result object is really a smart pointer so it can be copied around without incurring much cost in terms of performance. Don't check these for errors; failures show up as 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