summaryrefslogtreecommitdiff
path: root/src/postgresHandler.cpp
blob: 212202e61658418f75089862d5928427d8e125f1 (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
#include "postgresHandler.h"
#include <iostream>
#include <regex>

const pqxx::result execute_query(pqxx::work &t_transaction,
                                 std::string_view t_query) {
    return t_transaction.exec(t_query);
}

void display_query_result(const pqxx::result &t_r) {
    const int nb_columns = t_r.columns();
    for (const auto &row : t_r) {
        for (int i = 0; i < nb_columns; i++) {
            std::cout << row[i].c_str() << " | ";
        }
        std::cout << std::endl;
    }
}

void add_cards_to_database(std::string_view t_cards, pqxx::work &t_tx) {
    // TODO: to complete
    std::cout << "adding cards..." << std::endl;
    std::regex key_regex; // TODO: to define
    std::cout << t_cards.substr(1, 6) << std::endl;
}