Have you registered for CppCon 2015 in September? Don’t delay – Registration is open now.
While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2014 for you to enjoy. Here is today’s feature:
sqlpp11, An SQL Library Worthy Of Modern C++
by Roland Bock
Summary of the talk:
SQL and C++ are both strongly typed languages. They should play well together. But most C/C++ interfaces to SQL databases are string based. They force the developer to effectively hide the SQL types, names and expression structures from the compiler. This defers the validation of SQL expressions until runtime, i.e. unit tests or even production. And the strings might even be vendor specific, because different databases expect different dialects of SQL in those strings.
That feels wrong. Modern C++ can do better.
This talk gives an introduction to sqlpp11, a templated embedded domain specific language for SQL in C++. It allows you to build type-safe SQL expressions with type-safe results, all of which can be verified at compile time, long before your code enters unit tests or even production.
In addition to its obvious use with relational databases, sqlpp11 can also serve as an SQL frontend for all kinds of data sources: Since sqlpp11 offers complete SQL expression trees even at compile time, it isn't hard to apply SQL expressions to std::vector or std::map for instance, or streams, or XML, or JSON, you name it. With your help, sqlpp11 could become for C++ what LINQ is for C#.