summaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: bf1d53d95d6fc16181319482cabdccb6c3c4d48c (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
#include "hearthstoneAPIHandler.h"
#include "postgresHandler.h"
#include <iostream>
#include <pqxx/pqxx>

int main() {
    HearthstoneAPIHandler hs_handler;
    pqxx::connection cx{
        "postgresql://aotrix@localhost:5432/hearthstonegameinfo"};
    pqxx::work tx{cx};

    try {
        std::string cards = hs_handler.get_cards(
            "/108499?locale=fr_FR&gameMode=constructed&pageSize=2");
        std::cout << cards << std::endl;
        add_cards_to_database(cards, tx);
        tx.commit();
    } catch (pqxx::sql_error const &e) {
        std::cerr << "SQL error: " << e.what() << std::endl;
        std::cerr << "Query was: " << e.query() << std::endl;
        return 2;
    } catch (std::exception const &e) {
        std::cerr << "Error: " << e.what() << std::endl;
        return 1;
    }
    return 0;
}