Yet another PostgreSQL C++ binding
От | Phil Endecott |
---|---|
Тема | Yet another PostgreSQL C++ binding |
Дата | |
Msg-id | 1173477833822@dmwebmail.belize.chezphil.org обсуждение исходный текст |
Список | 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.)
В списке pgsql-general по дате отправления: