From 3cacf994c9c69dff16d5a7ea6672c3206f6285e8 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Tue, 2 Apr 2024 16:38:33 +0200 Subject: [PATCH] add additional information to SQLiteLogger --- src/loggers/bt_sqlite_logger.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/loggers/bt_sqlite_logger.cpp b/src/loggers/bt_sqlite_logger.cpp index 42ff49fd0..ca862bead 100644 --- a/src/loggers/bt_sqlite_logger.cpp +++ b/src/loggers/bt_sqlite_logger.cpp @@ -27,6 +27,11 @@ SqliteLogger::SqliteLogger(const Tree& tree, std::filesystem::path const& filepa "state INTEGER NOT NULL," "metadata VARCHAR );"); + sqlite::Statement(*db_, "CREATE TABLE IF NOT EXISTS Nodes (" + "session_id INTEGER NOT NULL, " + "fullpath VARCHAR, " + "uid INTEGER NOT NULL );"); + sqlite::Statement(*db_, "CREATE TABLE IF NOT EXISTS Definitions (" "session_id INTEGER PRIMARY KEY AUTOINCREMENT, " "date TEXT NOT NULL," @@ -50,6 +55,16 @@ SqliteLogger::SqliteLogger(const Tree& tree, std::filesystem::path const& filepa { session_id_ = res.Get(0); } + + for(const auto& subtree : tree.subtrees) + { + for(const auto& node : subtree->nodes) + { + sqlite::Statement(*db_, "INSERT INTO Nodes VALUES (?, ?, ?)", session_id_, + node->fullPath(), node->UID()); + } + } + writer_thread_ = std::thread(&SqliteLogger::writerLoop, this); }