summaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: 60c921f784f68130b80be05ebd24b3ed92385796 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "hearthstoneAPIHandler.h"
#include <iostream>
#include <pqxx/pqxx>

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<std::string>(),
            row[1].as<std::string>(), row[2].as<std::string>(),
            row[3].as<std::string>(), row[4].as<std::string>());
    }
}

int main() {
    HearthstoneAPIHandler hs_handler;
    hs_handler.get_cards("678?locale=en_US");

    pqxx::connection cx{
        "postgresql://aotrix@localhost:5432/hearthstonegameinfo"};
    pqxx::work tx{cx};
    display_query_result(execute_query(tx, "SELECT * FROM cards"));
    return 0;
}