-
Notifications
You must be signed in to change notification settings - Fork 1
/
pgbuilder.hpp
55 lines (41 loc) · 1.24 KB
/
pgbuilder.hpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#if !defined(PGBUILDER_HPP_INCLUDED)
#define PGBUILDER_HPP_INCLUDED
#include "csvbuilder.hpp"
#include "dbspec.hpp"
#include <string>
#include <vector>
#include <memory>
#include <pqxx/connection>
#include <pqxx/transaction>
#include <pqxx/tablewriter>
class pgcommon {
protected:
pqxx::connection &db;
std::string tablename;
pgcommon(pqxx::connection &db);
void add_index_impl(const std::string &column);
void open_table_impl(const table_spec &a_spec);
};
class pgbuilder : private pgcommon, public tablebuilder {
private:
std::vector<const char *> cur_row;
std::unique_ptr<pqxx::work> cur_work;
std::string cur_insert;
int cur_idx;
public:
pgbuilder(pqxx::connection &db);
virtual void open_table(const table_spec &spec);
virtual void table_complete();
virtual void open_row();
virtual void row_complete();
virtual void add_column(const column_spec &col, const char *value);
virtual void add_index(const std::string &column);
};
class pgcopybuilder : private pgcommon, public csvbuilder {
public:
pgcopybuilder(pqxx::connection &db, const std::string &tempdir);
virtual void open_table(const table_spec &a_spec);
virtual void table_complete();
virtual void add_index(const std::string &column);
};
#endif // PGBUILDER_HPP_INCLUDED