-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathodbc_connection.h
68 lines (57 loc) · 1.78 KB
/
odbc_connection.h
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once
#include "nanodbc.h"
#include "sql_types.h"
#include "time_zone.h"
#include <Rcpp.h>
// Important that this header is included after Rcpp.h
#include "Iconv.h"
namespace odbc {
enum bigint_map_t {
i64_to_integer64,
i64_to_integer,
i64_to_double,
i64_to_character,
};
class odbc_result;
class odbc_connection {
public:
friend odbc_result;
odbc_connection(
std::string const& connection_string,
std::string const& timezone = "UTC",
std::string const& timezone_out = "UTC",
std::string const& encoding = "",
std::string const& name_encoding = "",
bigint_map_t const& bigint_mapping = i64_to_integer64,
long const& timeout = 0,
Rcpp::Nullable<Rcpp::List> const& r_attributes = R_NilValue,
bool const& interruptible_execution = true);
std::shared_ptr<nanodbc::connection> connection() const;
void begin();
void commit();
void rollback();
bool has_active_result() const;
bool is_current_result(odbc_result* result) const;
bool supports_transactions() const;
bool get_data_any_order() const;
void cancel_current_result();
void set_current_result(odbc_result* r);
bool has_result() const;
cctz::time_zone timezone() const;
std::string timezone_out_str() const;
const std::shared_ptr<Iconv> output_encoder() const;
const std::shared_ptr<Iconv> column_name_encoder() const;
bigint_map_t get_bigint_mapping() const;
private:
std::shared_ptr<nanodbc::connection> c_;
std::unique_ptr<nanodbc::transaction> t_;
odbc_result* current_result_;
cctz::time_zone timezone_;
cctz::time_zone timezone_out_;
std::string timezone_out_str_;
bigint_map_t bigint_mapping_;
std::shared_ptr<Iconv> output_encoder_;
std::shared_ptr<Iconv> column_name_encoder_;
bool interruptible_execution_;
};
} // namespace odbc