#include #include #include #include #include void display_result(pqxx::result r) { // FIXME: not flexible for (auto row : r) { std::cout << std::format( "{}; {}; {}; {}; {}", row[0].as(), row[1].as(), row[2].as(), row[3].as(), row[4].as()); } } const pqxx::result execute_query(pqxx::work &transaction, std::string_view query) { return transaction.exec(query); } void do_curl_request(const char *url) { CURL *curl = curl_easy_init(); if (curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, url); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } } int main() { pqxx::connection cx{ "postgresql://aotrix@localhost:5432/hearthstonegameinfo"}; pqxx::work tx{cx}; std::string_view access_token{"EUCCbw5IzCx5gF4PMJLT7zGAFs0RSxRhqK"}; std::string_view header{ std::format("Authorization: Bearer {}", access_token)}; // TODO: add header to curl request do_curl_request( "https://eu.api.blizzard.com/hearthstone/cards/678?locale=fr_FR"); // display_result(execute_query(tx, "SELECT * FROM cards")); return 0; }