From: Kaj-Michael Lang Date: Tue, 5 Feb 2008 11:52:23 +0000 (+0200) Subject: Add transaction begin/commit helpers X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57982b353f5986189654bb51f0daa3874d24a74b;p=mapper Add transaction begin/commit helpers --- diff --git a/src/db.c b/src/db.c index 92ef0d8..9bf7636 100644 --- a/src/db.c +++ b/src/db.c @@ -133,6 +133,18 @@ if (db && *db) { return TRUE; } +gboolean +db_transaction_begin(sqlite3 *db) +{ +return db_exec_sql(db, "begin;"); +} + +gboolean +db_transaction_commit(sqlite3 *db) +{ +return db_exec_sql(db, "commit;"); +} + /** * Connect to given sqlite database * @@ -165,5 +177,3 @@ sqlite3_exec(*db, "PRAGMA cache_size = 8000;", NULL, NULL, NULL); return TRUE; } - - diff --git a/src/db.h b/src/db.h index 94ff03b..0949279 100644 --- a/src/db.h +++ b/src/db.h @@ -33,6 +33,9 @@ gboolean db_close(sqlite3 **db); gboolean db_exec_sql(sqlite3 *db, const gchar *sql); gboolean db_exec(sqlite3 *db, sqlite3_stmt *sql); +gboolean db_transaction_begin(sqlite3 *db); +gboolean db_transaction_commit(sqlite3 *db); + void db_create_tables(sqlite3 *db); void db_create_indexes(sqlite3 *db);