Yet another PostgreSQL C++ binding

From: "Phil Endecott" <spam_from_postgresql_general(at)chezphil(dot)org>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Yet another PostgreSQL C++ binding
Date: 2007-03-09 22:03:53
Message-ID: 1173477833822@dmwebmail.belize.chezphil.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear All,

I've written a C++ PostgreSQL interface library which I use in a couple
of open-source applications, and I thought that I would mention it here
in case it could be of use to anyone. Yes, I know there are already
several such libraries, but I believe mine has a unique feature:
queries are functors that use prepared statements. Here's an example:

Database db("dbname=foo, username=blah");
Query<string,int> insert_thing(db,"insert into things(name,num)
values ($1,$2)");
SingletonQuery<int, string> count_things(db,"select sum(num) from
things where name=$1");

Transaction t(db);
insert_thing("table",1);
insert_thing("chair",4);
int n = count_things("bed");
t.commit();

Note how the queries are declared using the $n placeholder syntax for
parameters. Once the queries are declared the fact that they are
queries can be almost forgotten - they can be used as functions.

I have written up some basic documentation here:

http://svn.chezphil.org/libpbe/trunk/doc/Database

Do let me know if you find this useful.

Regards,

Phil.

(I encourage you to Cc: me in any replies.)

Browse pgsql-general by date

  From Date Subject
Next Message Don Lavelle 2007-03-09 22:45:14 Re: Beginner's Questions
Previous Message Omar Eljumaily 2007-03-09 22:00:14 Re: Setting week starting day