#include #include #include #include #include #include "sqliteinterface.hpp" namespace fs = std::filesystem; using namespace std; void SqliteInterface::openDB() { fs::path appdata = DEF_APPDATA; if (!fs::exists(appdata)) { error_code ec; fs::create_directories(appdata, ec); if (ec.value() != 0) { char errmsg[] = "Can't create folder: "; strcat(errmsg, ec.message().c_str()); throw runtime_error(errmsg); } } fs::path filename = appdata / "ytcpp.db"; int rc = sqlite3_open(filename.c_str(), &db); if (rc) { char errmsg[] = "Can't open database: "; strcat(errmsg, sqlite3_errmsg(db)); throw runtime_error(errmsg); } } void SqliteInterface::closeDB() { sqlite3_close(db); } static int callback(void *NotUsed, int argc, char **argv, char **azColName) { int i; for(i = 0; i