Subject: Re: [boost] Boost.SQL?
From: Roland Bock (rbock_at_[hidden])
Date: 2010-09-15 07:02:56


On 09/15/2010 12:31 PM, Daniel Pfeifer wrote:
> A while back, I did some experiments with prepared statements and
> boost::function (see http://github.com/purpleKarrot/async-db).
>
> Have a look at the mysql example. As I recall, it did work.
> http://github.com/purpleKarrot/async-db/blob/master/examples/mysql.cpp
>
> I currently lack the time to work further on this, but if you
> concentrate on string generation (which I did not), there might be some
> interesting combinations.
>
> Something like this would be cool:
>
> . function<void(int, string, gregorian::date)> insert
> . = sql::bind(INSERT> INTO> users(id, name, registered),
> . VALUES(int_, string_, date_));
>
> . insert(1003, "Bob", gregorian::day_clock::local_day());
>
> cheers, Daniel
>
Nice!

I am aiming at a more verbatim syntax, like

typedef my_table<> t;

sql::insert<t>(t::id(1003), t::name("Bob"),
t::date(gregorian::day_clock::local_day());

or (if for instance date could be NULL or had a default value), this
should also work:

sql::insert<t>(t::name("Bob"), t::id(1003));

Thus, the order of arguments is irrelevant, their meaning is
self-explanatory (similar to Boost.Parameter), and some arguments are
not required if the table definition says that they are not required.

Not sure how far I get, but it is certainly possible :-)

How did you intend to maintain your table definitions (keep them in sync
with the actual tables of the database)?

Regards,

Roland