13 /* RAII wrapper to close a SQLite database automatically. */
19 operator sqlite3
* () { return db
; }
22 /* RAII wrapper to create and destroy SQLite prepared statements. */
26 sqlite3_stmt
* stmt
= 0;
28 void create(sqlite3
* db
, const std::string
& s
);
30 operator sqlite3_stmt
* () { return stmt
; }
32 /* Helper for binding / executing statements. */
35 friend struct SQLiteStmt
;
38 unsigned int curArg
= 1;
39 Use(SQLiteStmt
& stmt
);
45 /* Bind the next parameter. */
46 Use
& operator () (const std::string
& value
, bool notNull
= true);
47 Use
& operator () (int64_t value
, bool notNull
= true);
52 /* Execute a statement that does not return rows. */
55 /* For statements that return 0 or more rows. Returns true iff
56 a row is available. */
59 std::string
getStr(int col
);
60 int64_t getInt(int col
);
69 /* RAII helper that ensures transactions are aborted unless explicitly
76 SQLiteTxn(sqlite3
* db
);
84 MakeError(SQLiteError
, Error
);
85 MakeError(SQLiteBusy
, SQLiteError
);
87 [[noreturn
]] void throwSQLiteError(sqlite3
* db
, const format
& f
);
89 /* Convenience function for retrying a SQLite transaction when the
92 T
retrySQLite(std::function
<T()> fun
)
97 } catch (SQLiteBusy
& e
) {