Hi
Oops I should have RTFMed a bit more to refresh my memory before posting.
There are some significant differences.
To start things off (excuse errors due to failure to RTFM sufficiently):
DTL auto-prepares statements (would you ever not want to do this?)
You don't need to say select or insert its implicit in whether you are reading
or writing.
So you just specify one or more tables (joins just work!)
There's also a bulk fetch helper which can be used more efficiently than
iteration.
Its not clear to me when SOCI uses bulk fetch. If you use a vector of rows I
think it will just iterate?
Finally there is fine control over the mapping of datatypes (for reasons I
forget called a BCA in DTL,
and which in C++11 could be a lambda instead).
I think this is a little less awkward than specialising the type_conversion
template in SOCI
(though I am prepared to be shown wrong by any SOCI gurus)
E.g.
MyRowType rowbuf,
DBView<MyRowType> view("table1, table1",
BCA(rowbuf,
COLS["column1"] >>
rowbuf.column1 &&
COLS["column2"] >>
rowbuf.column2),
"where clause here if you want
it");
bulk_fetch_helper(view.begin(), 500,
std::ostream_iterator<MyRowType>(std::cout, "\n"));
So I think there is some room for improvement in SOCI on the ORM side.
I suspect a lot of the success of SOCI, in terms of attracting users, is based
on its ability to make queries look
like embedded SQL (but of course so much better).
I think the success of ORMs and DTL in particular is in hiding the database
wherever possible.
So from the ORM perspective embedding SQL seems like a horseless carriage
(see for example http://www.horton.com/beyondhcthandouts.htm)
The DTL documentation makes no bones about pushing for a modern design away
from the horseless carriage of embedded SQL.
SOCI on the other hand just leaves it to the user. Users coming from the a
background of using SQL directly on the database
will naturally be drawn to the embedded SQL way of thinking and hence prefer
that side of SOCI to its ORM offering.
Java programmers will be drawn the other way from using Hibernate/JPA.
My agenda here is simply that SOCI+DTL (or even +=) would form a good starting
point for a standard C++ database interface.
Now that its come up again in the context of C++1y with library proposals not
having to wait for a new standard
its worth giving more thought.
Regards,
Bruce.
>________________________________
> From: Mateusz Loskot <[email protected]>
>To: Bruce Adams <[email protected]>; SOCI general discussion list
><[email protected]>
>Sent: Friday, April 12, 2013 5:48 PM
>Subject: Re: [soci-users] The next three big things
>
>
>On 12 April 2013 16:16, Bruce Adams <[email protected]> wrote:
>> Thanks in part to my prompting the the author of DTL has posted in
>> regard to n3612
>>
>> https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/iqOtgxP_IRA
>
>Thanks for that. The whole discussion is very interesting.
>I will yet see, but despite I am subscribed to that mailing list,
>it is unlikely I will have time to dive into it myself, unfortunately.
>
>> One of the attractions of DTLs approach for me is illustrated by the example
>> of how to dump an entire table:
>
>> DynamicDBView<> view("DB_EXAMPLE", "*");
>> copy(view.begin(), view.end(), ostream_iterator<variant_row>(cout, "\n"));
>>
>> I never worked out if it was possible to be quite so elegant in SOCI. Is it?
>
>Yes, fancy :-)
>
>From the docs:
>
>rowset<std::string> rs = (sql.prepare << "select firstname from person");
>std::copy(rs.begin(), rs.end(),
>std::ostream_iterator<std::string>(std::cout, "\n"));
>
>change to rowset<row> and make row streamable.
>
>Best regards,
>--
>Mateusz Loskot, http://mateusz.loskot.net
>
>
>------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users