Boost logo

Boost :

Subject: [boost] SQL: next iteration of sqlpp11
From: Roland Bock (rbock_at_[hidden])
Date: 2014-02-01 09:04:58


Dear boosters,

after the lively discussion about sqlpp11 in November 2013
(http://lists.boost.org/Archives/boost/2013/11/208388.php), sqlpp11 has
evolved quite a bit and I want to give you an update.

https://github.com/rbock/sqlpp11

*) sqlpp11 now supports prepared statements.
   For instance

   auto ps = db.prepare(select(all_of(tab))
                       .from(tab)
                       .where(tab.alpha != parameter(tab.alpha)));
   ps.params.alpha = 42;
   for (const auto& row: db.run(ps))
   {
      std::cerr << "alpha: " << row.alpha << std::endl;
      std::cerr << "beta: " << row.beta << std::endl;
      std::cerr << "gamma: " << row.gamma << std::endl;
   }

*) Binding of parameters and results for binary transport is now
   supported.
   Both, parameters of prepared statements and results can be
   bound to in-memory data of the database now.

   In the example above, using the provided mysql connector, neither
   parameters nor the non-text results are converted to/from string.

*) Support for multi-row insert:
   //First, you create an insert:
   auto i = insert_into(tab).columns(tab.alpha, tab.beta);

   //Then you add values (one or more times):
   i.values(tab.alpha = 7, tab.beta = "seven");

   // Then you run the insert
   db.run(i);

   There is no support for array binding in sqlpp11, since this is
   highly vendor specific afaict. But it would be fairly easy to
   add support for this in the vendor-specific connector library. I'd
   be happy to support you if you wanted to give it a try.

*) New interpreter for SQL expression trees:
   This has changed and improved a lot. sqlpp11 has been stripped
   of all vendor specific code and will serialize standard SQL.
   The connector libraries can specialize an interpreter template to
   change the representation of certain aspects. For instance, mysql
   would represent the concatenation of strings as CONCAT(a,b)
   instead of a||b.

   But of course, the connector libraries are not required to turn
   the expression into a string. They can interpret it any way they
   like. I strongly believe that this is going to allow for writing
   connectors to XML, input streams, maps, etc. (think LINQ).

*) I added a sample code generator (in python) that generates table
   representations from a DDL

Todo-List:
----------
*) More thorough documentation
*) More thorough and easier to comprehend tests
*) Some of you mentioned that Boost.Fusion or Boost.Preprocessor
   might do be able to do the job of code generation very elegantly.
   I won't do that myself
   but I'd be interested to see such solutions.
   Since code generation is not integral part of the library
   it would make sense to have such solutions as support libraries.
*) Look into cursors

FYI, I am going to give a talk about sqlpp11 and some template
patterns used inside of it on February 27 in Munich, see
http://www.meetup.com/MUCplusplus/events/160688442/

Please let me know your questions/thoughts/suggestions/rants.
Contributions welcome, of course :-)

Regards,

Roland

PS: Given enough interest, I intend to officially propose the library to
boost (after several more iterations, of course). This is why I hope it
is OK to discuss sqlpp11 on this mailing list every now and then.


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