2022-02-22 20:33:45 +08:00
|
|
|
// Copyright 2022 Memgraph Ltd.
|
2021-10-26 14:53:56 +08:00
|
|
|
//
|
|
|
|
// Use of this software is governed by the Business Source License
|
|
|
|
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
|
|
|
// License, and you may not use this file except in compliance with the Business Source License.
|
|
|
|
//
|
|
|
|
// As of the Change Date specified in that file, in accordance with
|
|
|
|
// the Business Source License, use of this software will be governed
|
|
|
|
// by the Apache License, Version 2.0, included in the file
|
|
|
|
// licenses/APL.txt.
|
|
|
|
|
2020-03-03 17:38:50 +08:00
|
|
|
#include <gflags/gflags.h>
|
|
|
|
|
|
|
|
#include "communication/bolt/client.hpp"
|
|
|
|
#include "io/network/endpoint.hpp"
|
|
|
|
#include "io/network/utils.hpp"
|
2021-01-21 22:47:56 +08:00
|
|
|
#include "utils/logging.hpp"
|
2020-03-03 17:38:50 +08:00
|
|
|
|
|
|
|
DEFINE_string(address, "127.0.0.1", "Server address");
|
|
|
|
DEFINE_int32(port, 7687, "Server port");
|
|
|
|
DEFINE_string(username, "", "Username for the database");
|
|
|
|
DEFINE_string(password, "", "Password for the database");
|
|
|
|
DEFINE_bool(use_ssl, false, "Set to true to connect with SSL to the server.");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes "DUMP DATABASE" and outputs all results to stdout. On any errors it
|
|
|
|
* exits with a non-zero exit code.
|
|
|
|
*/
|
|
|
|
// NOLINTNEXTLINE(bugprone-exception-escape)
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::logging::RedirectToStderr();
|
2020-03-03 17:38:50 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::communication::SSLInit sslInit;
|
2020-03-03 17:38:50 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::io::network::Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port);
|
2020-03-03 17:38:50 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::communication::ClientContext context(FLAGS_use_ssl);
|
|
|
|
memgraph::communication::bolt::Client client(&context);
|
2020-03-03 17:38:50 +08:00
|
|
|
|
|
|
|
client.Connect(endpoint, FLAGS_username, FLAGS_password);
|
|
|
|
auto ret = client.Execute("DUMP DATABASE", {});
|
|
|
|
for (const auto &row : ret.records) {
|
2021-02-18 22:32:43 +08:00
|
|
|
MG_ASSERT(row.size() == 1, "Too much entries in query dump row (got {}, expected 1)!", row.size());
|
2020-03-03 17:38:50 +08:00
|
|
|
std::cout << row[0].ValueString() << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|