I also wasn't pleased with what I could find. Now you can write:
class Person {
public:
Person() {}
static SqlTable<Person>& table() {
static SqlTable<Person> tab = SqlTable<Person>::sqlTable("Person",
SqlColumn<Person>("Firstname", makeAttr(&Person::firstname)),
SqlColumn<Person>("Lastname", makeAttr(&Person::lastname)),
SqlColumn<Person>("Age", makeAttr(&Person::age)),
return tab;
}
std::string firstname;
std::string lastname;
int age;
};
SqliteDB db("testtable.db");
auto sel(db.select<Person>("Firstname=\"Danny\" and Lastname=\"Zeckzer\""));
std::for_each(sel.first, sel.second, [](const Person& p) {
...
Person me;
db.insert<Person>(me);
...
std::vector<Person> everybody;
db.insert<Person>(everybody.begin(), everybody.end());
The table method is all you need to write as long as you stick to the sqlite3 data types. As everything is a template not much abstraction layer code remains after -O. Natural joins require a result class similar to the Person class. The implementation is a single header with less than 500 lines. License is LGPL. Source