Boost logo

Boost :

Subject: Re: [boost] sqlpp11: SQL for C++
From: TONGARI J (tongari95_at_[hidden])
Date: 2013-11-11 10:00:33


Hi,

2013/11/10 Roland Bock <rbock_at_[hidden]>

> Hi,
>
> over the last four or five years I developed several SQL libraries for
> C++. With C++11 I was finally able to create an SQL library that meets
> my own expectations and requirements. It is being used in production, I
> recently put it on github, and I would really like to hear from you guys
> whether this is something that could be interesting for you personally
> or for boost?
>
> https://github.com/rbock/sqlpp11
> https://github.com/rbock/sqlpp11/wiki
>

That's almost what I was looking for :D

Thus far, I used SOCI with my query wrapper like below:

    BOOST_FUSION_DEFINE_STRUCT
    (
        (opti), user,
        (std::string, account)
        (std::string, pwd)
        (std::string, name)
        (unsigned, role)
    )

soci::session sql;
    query<with_id<user>*()> query_users(sql, "SELECT id, account, pwd,
name, role FROM user";

    for (auto&& user : query_users()) {...}

> --------------
> // selecting zero or more results, iterating over the results
> for (const auto& row : db.run(
> select(foo.name, foo.hasFun)
> .from(foo)
> .where(foo.id > 17 and foo.name.like("%bar%"))))
>

Is it possible to separate the placeholders of columns & tables? I feel it
redundant to say table.column if not ambiguous.
In case of more than one table, maybe table[column] is a good syntax for
that.

Does it support prepared statement?
Maybe another set of placeholders (_1, _2, ...) can be used to generate the
functor.

Also, it'll be great if it works with Fusion & Optional, etc...

{
> if (row.name.is_null())
> std::cerr << "name will convert to empty string" << std::endl;
> std::string name = row.name; // text fields are implicitly
> convertible to string
> bool hasFun = hasFun; // bool fields are implicitly
> convertible to bool
> }
>
> Dynamic Select:
> ----------------
> auto s = dynamic_select(db, tab.foo).dynamic_columns().from(tab);
> if (userWantsBar)
> s.add_column(tab.bar);
> for(const auto& row : run(s))
> {
> std::cerr << "row.foo: " << row.foo;
> if (userWantsBar)
> std::cerr << "row.bar" << row.at("bar");
> std::cerr << std::endl;
> };
>
>
> Please let me know your questions/thoughts/suggestions/rants.
> Contributions welcome, of course :-)
>
>
> Regards,
>
> Roland
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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