I read this post and tried some of the libraries mentioned in the answers ,
But none of them was easy enough for me ( i am a lazy programmer ! ).
So i wrote my own wrapper : sqlite modern cpp
database db("dbfile.db");
// executes the query and creates a 'user' table if not exists
db << "create table if not exists user ("
" age int,"
" name text,"
" weight real"
");";
// inserts a new user and binds the values to '?' marks
db << "insert into user (age,name,weight) values (?,?,?);"
<< 20
<< "bob"
<< 83.0;
// slects from table user on a condition ( age > 18 ) and executes
// the lambda for every row returned .
db << "select age,name,weight from user where age > ? ;"
<< 18
>> [&](int age, string name, double weight) {
cout << age << ' ' << name << ' ' << weight << endl;
};
// selects the count(*) of table user
int count = 0;
db << "select count(*) from user" >> count;
Have fun !