Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2004-10-13 10:20:30


On Tue, 12 Oct 2004 21:54:21 -0400, Tito Villalobos wrote
> I have been working on a library for database programming. It
> currently wraps only ODBC API, though the same interface will be
> able to be created over the ADO API as well. It appears that the
> MySQL and PostgreSQL would be fairly straight forward to wrap as
> well, though I do not know those API's (yet).

Their are ODBC drivers for mysql available and I think Postgres as well.

http://dev.mysql.com/downloads/connector/odbc/3.51.html

So I think ODBC is clearly the right first target.

> The core goal is to reduce the amount of overhead and boilerplate
> code that database programming currently requires. I wanted the
> type safety and speed of statically typed recordsets without
> resorting to "each recordset is a whole new class" that is so common
> typesafe ODBC and IADORecordBinding (ADO) based recordsets. On the
> other hand, latebound "variant" based recordsets (ADO) are somewhat
> painful to use in a strongly typed language like C++, and inevitably
> result in quite a bit of code. Common relational database concepts
> apply across all of the various database API's, and it should be
> possible to encapsulate them all in a way that allows flexibility in
> what is used underneath, with few in client code.

Yes, agreed.

> The core of the interesting piece is the recordset/statement, as
> connection and such are pretty standard. The implementation uses
> mpl and tuples to avoid the need to create a ton of new classes and
> complicated bindings. It also uses traits to directly map C++ types
> to the correct ODBC bindings without any extra work for the client.
>
> The syntax for declaring the a statement is:
>
>...snip code...

The one concern I have is that many db applications require runtime schema
discovery as well as data returns -- so I think the compile time approach is
limited to a particular class of applications that can be fully specified at
compile time. DTL has dynamic views and integrates well with STL collections,
so at some level they are setting the standard on this currently. Another
interesting area of exploration for this would be integration with
boost.multi_index.
 
> Would there be any interest in including this in boost?

Yes, we really need a standard well thought out approach to accessing
databases in C++.

Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk