From 332c0ffde6d60b7bac3cb14df31cbae3f27383a7 Mon Sep 17 00:00:00 2001 From: Aotrix Date: Tue, 18 Mar 2025 19:21:57 +0100 Subject: added postgres handler --- src/main.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 90a4fe6..6786a5b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,29 +1,20 @@ #include "hearthstoneAPIHandler.h" +#include "postgresHandler.h" #include #include -const pqxx::result execute_query(pqxx::work &t_transaction, - std::string_view t_query) { - return t_transaction.exec(t_query); -} - -void display_query_result(pqxx::result t_r) { - // FIXME: not flexible - for (auto row : t_r) { - std::cout << std::format( - "{}; {}; {}; {}; {}", row[0].as(), - row[1].as(), row[2].as(), - row[3].as(), row[4].as()); - } -} - int main() { HearthstoneAPIHandler hs_handler; - std::cout << hs_handler.get_cards("678?locale=en_US") << std::endl; + // TODO: use a parser on get_cards returned value + std::cout << hs_handler.get_cards("678?locale=fr_FR") << std::endl; pqxx::connection cx{ "postgresql://aotrix@localhost:5432/hearthstonegameinfo"}; pqxx::work tx{cx}; display_query_result(execute_query(tx, "SELECT * FROM cards")); + + // TODO: for test purposes + // use get_cards output instead? + add_cards_to_database("{\"name\":3}", tx); return 0; } -- cgit v1.2.3