Kira said:
I apologize if this is an off topic question, but I am not sure where is
the right forum to ask this:
I was wondering what are the currently popular choices for database
connectivity in C++.
Is there a standard being worked on that will become the C++ equivalence
of java's JDBC?
There's something called ODBC which is supposed to be the equivalent.
I've not used it. In my experience, almost any non-trivial SQL
application will use implementation-specific features; once you're in
this situation you may as well use a database-specific access library.
My own attempt at turning SQL queries into C++ functors for PostgreSQL,
implemented on top of the PostgreSQL C API, can be found here:
http://svn.chezphil.org/libpbe/trunk/include/Database.hh
It lets you declare queries something like this:
SingletonQuery<string, int>
get_user_name_from_id(db,"select name from users where id=$1");
The template parameters to Query are the result and parameter types
respectively. You can then invoke it as a functor:
string n = get_user_name_from_id(1234);
The query is prepared when declared and invoked using PostgreSQL's
binary API, so there's no serialisation/deserialisation going on between
the application and the database. We also get reasonably strong type
checking.
Regards, Phil.