blob: 90a4fe688868d0af227dc57766e6078b88153494 (
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;
std::cout << hs_handler.get_cards("678?locale=en_US") << std::endl;
pqxx::connection cx{
"postgresql://aotrix@localhost:5432/hearthstonegameinfo"};
pqxx::work tx{cx};
display_query_result(execute_query(tx, "SELECT * FROM cards"));
return 0;
}
|