-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathserial_import.cpp
More file actions
56 lines (48 loc) · 1.78 KB
/
Copy pathserial_import.cpp
File metadata and controls
56 lines (48 loc) · 1.78 KB
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
// Copyright (C) 2016-2023 Memgraph Ltd. [https://memgraph.com]
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "serial_import.hpp"
namespace mode::serial_import {
using namespace std::string_literals;
int Run(const utils::bolt::Config &bolt_config, const format::CsvOptions &csv_opts,
const format::OutputOptions &output_opts) {
auto session = MakeBoltSession(bolt_config);
if (session.get() == nullptr) {
return 1;
}
while (true) {
auto query = query::GetQuery(nullptr);
if (!query) {
break;
}
if (query->query.empty()) {
continue;
}
try {
auto ret = query::ExecuteQuery(session.get(), query->query);
if (!ret.records_as_strings.empty()) {
format::Output(ret.header, ret.records_as_strings, output_opts, csv_opts);
}
} catch (const utils::ClientQueryException &e) {
console::EchoFailure("Failed query", query->query);
console::EchoFailure("Client received query exception", e.what());
return 1;
} catch (const utils::ClientFatalException &e) {
console::EchoFailure("Client received connection exception", e.what());
return 1;
}
}
return 0;
}
} // namespace mode::serial_import