diff options
author | ComradeCrow <comradecrow@vivaldi.net> | 2023-04-20 00:16:53 -0700 |
---|---|---|
committer | ComradeCrow <comradecrow@vivaldi.net> | 2023-04-20 00:16:53 -0700 |
commit | 7ba81cbe9809cfb68bee85bc6f79e798ef7b05ce (patch) | |
tree | 1daea06ae7663adb6ae4a56a90bc95fea9ea3c57 /src | |
parent | bc48d6f7bf88d89846d9eabffc67cedeb312c273 (diff) | |
download | ytcpp-7ba81cbe9809cfb68bee85bc6f79e798ef7b05ce.tar.gz |
start basic database support
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 9 | ||||
-rw-r--r-- | src/sqliteinterface.cpp | 25 | ||||
-rw-r--r-- | src/sqliteinterface.hpp | 2 |
3 files changed, 31 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 992761a..c08ba75 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,7 @@ #include "tui.hpp" #include "invapi.hpp" #include "YtdlpWrapper.hpp" +#include "sqliteinterface.hpp" namespace py = pybind11; @@ -17,9 +18,11 @@ using namespace std; int main() { - YtdlpWrapper yt; - nlohmann::json j = yt.getJsonSearch("the very thought of you"); - cout << j << endl; + // YtdlpWrapper yt; + // nlohmann::json j = yt.getJsonSearch("the very thought of you"); + // cout << j << endl; + + openDB(); // vector<string> instances = getInstances(); // for (auto i: instances) { diff --git a/src/sqliteinterface.cpp b/src/sqliteinterface.cpp index 6b244dc..96e4020 100644 --- a/src/sqliteinterface.cpp +++ b/src/sqliteinterface.cpp @@ -1,3 +1,26 @@ -#include <string> #include <sqlite3.h> +#include <iostream> +#include <cstring> +#include <filesystem> #include "sqliteinterface.hpp" + +void openDB() { + + sqlite3 *db; + + + char filename[] = DEF_APPDATA; + strcat(filename, "ytcpp.db"); + int rc = sqlite3_open(filename, &db); + + if( rc ) { + + char errmsg[] = "Can't open database: "; + strcat(errmsg, sqlite3_errmsg(db)); + std::cerr << errmsg << std::endl; + } else { + + std::cout << "Opened database successfully" << std::endl; + sqlite3_close(db); + } +} \ No newline at end of file diff --git a/src/sqliteinterface.hpp b/src/sqliteinterface.hpp index 6a38d2c..4a18f85 100644 --- a/src/sqliteinterface.hpp +++ b/src/sqliteinterface.hpp @@ -3,5 +3,5 @@ #include <string> #include <sqlite3.h> - +void openDB(); #endif \ No newline at end of file |