From ad68bbd4122683ac1ac00ebfeea6cdcfaae40777 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 5 Dec 2019 11:22:42 -0500 Subject: Import in one transaction per file --- database.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'database.h') diff --git a/database.h b/database.h index 3247fee..038ce70 100644 --- a/database.h +++ b/database.h @@ -94,6 +94,16 @@ static inline sqlite3 *dbFind(int flags) { return NULL; } +static inline void dbBegin(sqlite3 *db) { + int error = sqlite3_exec(db, "BEGIN TRANSACTION;", NULL, NULL, NULL); + if (error) errx(EX_SOFTWARE, "sqlite3_exec: %s", sqlite3_errmsg(db)); +} + +static inline void dbCommit(sqlite3 *db) { + int error = sqlite3_exec(db, "COMMIT TRANSACTION;", NULL, NULL, NULL); + if (error) errx(EX_SOFTWARE, "sqlite3_exec: %s", sqlite3_errmsg(db)); +} + static inline sqlite3_stmt * dbPrepare(sqlite3 *db, unsigned flags, const char *sql) { sqlite3_stmt *stmt; -- cgit 1.4.1