11static void exec(sqlite3* db,
const char* sql) {
13 if (sqlite3_exec(db, sql,
nullptr,
nullptr, &err) != SQLITE_OK) {
14 std::string e = err ? err :
"unknown";
18 throw std::runtime_error(e);
24 throw std::runtime_error(
"db is null");
27 exec(db_,
"BEGIN IMMEDIATE;");
37 exec(db_,
"ROLLBACK;");
static void exec(sqlite3 *db, const char *sql)
static void exec(sqlite3 *db, const char *sql)
Declares a lightweight SQLite transaction guard.
void commit()
Commit the transaction.
SqliteTransaction(sqlite3 *db)
Start a SQLite transaction.
~SqliteTransaction()
Roll back the transaction unless it was committed.