From 7ba81cbe9809cfb68bee85bc6f79e798ef7b05ce Mon Sep 17 00:00:00 2001 From: ComradeCrow Date: Thu, 20 Apr 2023 00:16:53 -0700 Subject: start basic database support --- src/main.cpp | 9 ++++++--- src/sqliteinterface.cpp | 25 ++++++++++++++++++++++++- src/sqliteinterface.hpp | 2 +- 3 files changed, 31 insertions(+), 5 deletions(-) (limited to 'src') 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 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 #include +#include +#include +#include #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 #include - +void openDB(); #endif \ No newline at end of file -- cgit 1.4.1-2-gfad0