Boost logo

Boost :

Subject: Re: [boost] SQL client library ?
From: joel (joel.falcou_at_[hidden])
Date: 2009-09-06 05:14:16


Jean-Louis Leroy wrote:
> 2. It looks like the options they are considering for a syntax are
> mainly inspired by Soci and pqxx. They have this in common : the query
> is expressed as SQL text (à la Boost.Regex) that is parsed at run time
> instead of using language constructs (à la Boost.Xpressive) that can
> be checked at compile time. This is error prone : you can pass illegal
> SQL ; and the returned values will incur runtime typecasting, which
> may fail at run time in case of mismatch.
Back at Boost'Con 09 I proposed a function based and not text based SQL
interface using proto that looked like :

#include <boost/rdb_proto/rdb.hpp>

BOOST_RDB_REGISTER_FIELD(age,int)
BOOST_RDB_REGISTER_FIELD(id ,int)
BOOST_RDB_REGISTER_NAMED_FIELD(name,std::string,"complete_name")

int main()
{
  connection db("some.db.url","login","passwd");

  BOOST_RDB_TABLE((id)(name)(age)) employee("employee",db);
  BOOST_RDB_RESULT_SET((age)(name)) rows;

  rows = select(age,name).from(employee)
                                           .where( age > 45 && name
~= "Dil%" );

  // Some random access
  if( !r.empty() )
    cout << r[0][name] << " is "
         << r[0][age] << " years old." << endl;
}

I have the whole ppt of my proposal somewhere if soemone's interested.
I have alas not much free time for this but I had some prototype code
laying somewhere

-- 
___________________________________________
Joel Falcou - Assistant Professor
PARALL Team - LRI - Universite Paris Sud XI
Tel : (+33)1 69 15 66 35

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