]> git.sesse.net Git - nageru/blobdiff - db.cpp
Change from file-per-frame to multiple files per frame.
[nageru] / db.cpp
diff --git a/db.cpp b/db.cpp
index 77e3b73e09e9417dcea301528db398fdc8beb666..c3e647cf46343885360c58007da9d970aabe80af 100644 (file)
--- a/db.cpp
+++ b/db.cpp
@@ -4,17 +4,20 @@
 
 using namespace std;
 
-DB::DB(const char *filename)
+DB::DB(const std::string &filename)
 {
-       int ret = sqlite3_open(filename, &db);
+       int ret = sqlite3_open(filename.c_str(), &db);
        if (ret != SQLITE_OK) {
-               fprintf(stderr, "%s: %s\n", filename, sqlite3_errmsg(db));
+               fprintf(stderr, "%s: %s\n", filename.c_str(), sqlite3_errmsg(db));
                exit(1);
        }
 
        sqlite3_exec(db, R"(
                CREATE TABLE IF NOT EXISTS state (state BLOB);
        )", nullptr, nullptr, nullptr);  // Ignore errors.
+
+       sqlite3_exec(db, "PRAGMA journal_mode=WAL", nullptr, nullptr, nullptr);  // Ignore errors.
+       sqlite3_exec(db, "PRAGMA synchronous=NORMAL", nullptr, nullptr, nullptr);  // Ignore errors.
 }
 
 StateProto DB::get_state()