So I try simple sqlite3pp modified a bit code:
#include <iostream>
#include <sqlite3pp.h>
using namespace std;
int main(int argc, char* argv[])
{
try {
sqlite3pp::database db("test.db");
{
db.execute("CREATE TABLE IF NOT EXISTS users ( email varchar(65) primary key, pass varchar(65))");
db.execute("INSERT INTO users (email, pass) VALUES ('AAAA', '1234')");
}
{
sqlite3pp::transaction xct(db);
sqlite3pp::command cmd(db, "INSERT INTO users (email, pass) VALUES (?, ?)");
cout << cmd.bind(1, "BBBB") << endl;
cout << cmd.bind(2, "1234") << endl;
cout << cmd.execute() << endl;
cout << cmd.reset() << endl;
cmd.binder() << "CCCC" << "1234";
cout << cmd.execute() << endl;
xct.commit();
}
{
sqlite3pp::transaction xct(db, true);
sqlite3pp::command cmd(db, "INSERT INTO users (email, pass) VALUES (:name, :name)");
cout << cmd.bind(":name", "DDDD") << endl;
cout << cmd.execute() << endl;
}
}
catch (exception& ex) {
cout << ex.what() << endl;
}
cin.get();
}
First time it gives such output:
0
0
0
0
0
0
0
And on second time and forward when I execute it:
0
0
1
19
1
column email is not unique
Why it does not throw any error sooner than 5th (SQL error codes)?
Having had a quick look in the implementation of sqlite3pp, it seems stuff tends to just return error codes, and expects you to check them; it looked like it could be the destructor for the transaction that is throwing an exception, which is why you see your error message at the point that you do.