@@ -11,45 +11,48 @@ Rcpp::DataFrame list_drivers_() {
11
11
std::vector<std::string> names;
12
12
std::vector<std::string> attributes;
13
13
std::vector<std::string> values;
14
- for (auto & driver : nanodbc::list_drivers ()) {
14
+ for (auto & driver : nanodbc::list_drivers ()) {
15
15
if (driver.attributes .size () == 0 ) {
16
16
names.push_back (driver.name );
17
17
attributes.push_back (" " );
18
18
values.push_back (" " );
19
19
} else {
20
- for (auto & attr : driver.attributes ) {
20
+ for (auto & attr : driver.attributes ) {
21
21
names.push_back (driver.name );
22
22
attributes.push_back (attr.keyword );
23
23
values.push_back (attr.value );
24
24
}
25
25
}
26
26
}
27
27
return Rcpp::DataFrame::create (
28
- Rcpp::_[" name" ] = names, Rcpp::_[" attribute" ] = attributes,
29
- Rcpp::_[" value" ] = values, Rcpp::_[" stringsAsFactors" ] = false );
28
+ Rcpp::_[" name" ] = names,
29
+ Rcpp::_[" attribute" ] = attributes,
30
+ Rcpp::_[" value" ] = values,
31
+ Rcpp::_[" stringsAsFactors" ] = false );
30
32
}
31
33
32
34
// [[Rcpp::export]]
33
35
Rcpp::DataFrame list_data_sources_ () {
34
36
std::vector<std::string> names;
35
37
std::vector<std::string> descriptions;
36
- for (auto & data_source : nanodbc::list_data_sources ()) {
38
+ for (auto & data_source : nanodbc::list_data_sources ()) {
37
39
names.push_back (data_source.name );
38
40
descriptions.push_back (data_source.description );
39
41
}
40
- return Rcpp::DataFrame::create (Rcpp::_[" name" ] = names,
41
- Rcpp::_[" description" ] = descriptions,
42
- Rcpp::_[" stringsAsFactors" ] = false );
42
+ return Rcpp::DataFrame::create (
43
+ Rcpp::_[" name" ] = names,
44
+ Rcpp::_[" description" ] = descriptions,
45
+ Rcpp::_[" stringsAsFactors" ] = false );
43
46
}
44
47
45
48
// [[Rcpp::export]]
46
- connection_ptr odbc_connect (std::string const &connection_string,
47
- std::string const & timezone = " " ) {
49
+ connection_ptr odbc_connect (
50
+ std::string const & connection_string, std::string const & timezone = " " ) {
48
51
return connection_ptr (new std::shared_ptr<odbc_connection>(
49
52
new odbc_connection (connection_string, timezone )));
50
53
}
51
54
52
- std::string get_info_or_empty (connection_ptr const & p, short type) {
55
+ std::string get_info_or_empty (connection_ptr const & p, short type) {
53
56
try {
54
57
return (*p)->connection ()->get_info <std::string>(type);
55
58
} catch (nanodbc::database_error c) {
@@ -58,13 +61,14 @@ std::string get_info_or_empty(connection_ptr const &p, short type) {
58
61
}
59
62
60
63
// [[Rcpp::export]]
61
- Rcpp::List connection_info (connection_ptr const & p) {
64
+ Rcpp::List connection_info (connection_ptr const & p) {
62
65
return Rcpp::List::create (
63
66
Rcpp::_[" dbname" ] = get_info_or_empty (p, SQL_DATABASE_NAME),
64
67
Rcpp::_[" dbms.name" ] = get_info_or_empty (p, SQL_DBMS_NAME),
65
68
Rcpp::_[" db.version" ] = get_info_or_empty (p, SQL_DBMS_VER),
66
69
Rcpp::_[" username" ] = get_info_or_empty (p, SQL_USER_NAME),
67
- Rcpp::_[" host" ] = " " , Rcpp::_[" port" ] = " " ,
70
+ Rcpp::_[" host" ] = " " ,
71
+ Rcpp::_[" port" ] = " " ,
68
72
Rcpp::_[" sourcename" ] = get_info_or_empty (p, SQL_DATA_SOURCE_NAME),
69
73
Rcpp::_[" servername" ] = get_info_or_empty (p, SQL_SERVER_NAME),
70
74
Rcpp::_[" drivername" ] = get_info_or_empty (p, SQL_DRIVER_NAME),
@@ -75,38 +79,40 @@ Rcpp::List connection_info(connection_ptr const &p) {
75
79
}
76
80
77
81
// [[Rcpp::export]]
78
- std::string connection_quote (connection_ptr const & p) {
82
+ std::string connection_quote (connection_ptr const & p) {
79
83
return get_info_or_empty (p, SQL_IDENTIFIER_QUOTE_CHAR);
80
84
}
81
85
82
86
// [[Rcpp::export]]
83
87
void connection_release (connection_ptr p) {
84
88
if (p.get () != nullptr && (*p)->has_active_result ()) {
85
89
Rcpp::warning (
86
- " %s\n %s" , " There is a result object still in use." ,
90
+ " %s\n %s" ,
91
+ " There is a result object still in use." ,
87
92
" The connection will be automatically released when it is closed" );
88
93
}
89
94
p.release ();
90
95
}
91
96
92
97
// [[Rcpp::export]]
93
- void connection_begin (connection_ptr const & p) { (*p)->begin (); }
98
+ void connection_begin (connection_ptr const & p) { (*p)->begin (); }
94
99
95
100
// [[Rcpp::export]]
96
- void connection_commit (connection_ptr const & p) { (*p)->commit (); }
101
+ void connection_commit (connection_ptr const & p) { (*p)->commit (); }
97
102
98
103
// [[Rcpp::export]]
99
- void connection_rollback (connection_ptr const & p) { (*p)->rollback (); }
104
+ void connection_rollback (connection_ptr const & p) { (*p)->rollback (); }
100
105
101
106
// [[Rcpp::export]]
102
- bool connection_valid (connection_ptr const & p) { return p.get () != nullptr ; }
107
+ bool connection_valid (connection_ptr const & p) { return p.get () != nullptr ; }
103
108
104
109
// [[Rcpp::export]]
105
- Rcpp::DataFrame connection_sql_tables (connection_ptr const &p,
106
- std::string const &catalog_name = " " ,
107
- std::string const &schema_name = " " ,
108
- std::string const &table_name = " " ,
109
- std::string const &table_type = " " ) {
110
+ Rcpp::DataFrame connection_sql_tables (
111
+ connection_ptr const & p,
112
+ std::string const & catalog_name = " " ,
113
+ std::string const & schema_name = " " ,
114
+ std::string const & table_name = " " ,
115
+ std::string const & table_type = " " ) {
110
116
auto c = nanodbc::catalog (*(*p)->connection ());
111
117
auto tables =
112
118
c.find_tables (table_name, table_type, schema_name, catalog_name);
@@ -124,18 +130,22 @@ Rcpp::DataFrame connection_sql_tables(connection_ptr const &p,
124
130
catalog.push_back (tables.table_catalog ());
125
131
}
126
132
return Rcpp::DataFrame::create (
127
- Rcpp::_[" table_catalog" ] = catalog, Rcpp::_[" table_name" ] = names,
128
- Rcpp::_[" table_type" ] = types, Rcpp::_[" table_schema" ] = schemas,
129
- Rcpp::_[" table_remarks" ] = remarks, Rcpp::_[" stringsAsFactors" ] = false );
133
+ Rcpp::_[" table_catalog" ] = catalog,
134
+ Rcpp::_[" table_name" ] = names,
135
+ Rcpp::_[" table_type" ] = types,
136
+ Rcpp::_[" table_schema" ] = schemas,
137
+ Rcpp::_[" table_remarks" ] = remarks,
138
+ Rcpp::_[" stringsAsFactors" ] = false );
130
139
}
131
140
132
141
// "%" is a wildcard for all possible values
133
142
// [[Rcpp::export]]
134
- Rcpp::DataFrame connection_sql_columns (connection_ptr const &p,
135
- std::string const &column_name = " " ,
136
- std::string const &catalog_name = " " ,
137
- std::string const &schema_name = " " ,
138
- std::string const &table_name = " " ) {
143
+ Rcpp::DataFrame connection_sql_columns (
144
+ connection_ptr const & p,
145
+ std::string const & column_name = " " ,
146
+ std::string const & catalog_name = " " ,
147
+ std::string const & schema_name = " " ,
148
+ std::string const & table_name = " " ) {
139
149
auto c = nanodbc::catalog (*(*p)->connection ());
140
150
auto tables =
141
151
c.find_columns (column_name, table_name, schema_name, catalog_name);
@@ -151,6 +161,8 @@ Rcpp::DataFrame connection_sql_columns(connection_ptr const &p,
151
161
nullable.push_back (static_cast <bool >(tables.nullable ()));
152
162
}
153
163
return Rcpp::DataFrame::create (
154
- Rcpp::_[" name" ] = names, Rcpp::_[" field.type" ] = field_type,
155
- Rcpp::_[" nullable" ] = nullable, Rcpp::_[" stringsAsFactors" ] = false );
164
+ Rcpp::_[" name" ] = names,
165
+ Rcpp::_[" field.type" ] = field_type,
166
+ Rcpp::_[" nullable" ] = nullable,
167
+ Rcpp::_[" stringsAsFactors" ] = false );
156
168
}
0 commit comments