From c1e8ddb41af870d5536262160c57b57699dae622 Mon Sep 17 00:00:00 2001 From: Mars Ultor Date: Tue, 23 Dec 2025 23:32:40 -0600 Subject: [PATCH] clickhouse connection operational --- src/main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c4f6a38..5c43321 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,17 +1,26 @@ +#include "clickhouse/client.h" #include "spdlog/spdlog.h" +#include #include +#include #include int main (int argc, char *argv[]) { auto config = toml::parse_file("config.toml"); bool ingest_all_logs = config["all"].value_or(false); + std::string user_id = config["user_id"].value_or("kid"); std::string log_path = config["minecraft"]["logs_path"].value_or(""); if(log_path.empty()) throw std::runtime_error("your dumbass can't put in a path"); std::string clickhouse_username = config["clickhouse"]["username"].value_or(""); std::string clickouse_password = config["clickhouse"]["password"].value_or(""); std::string clickhouse_db = config["clickhouse"]["db"].value_or(""); - if(clickhouse_username.empty() || clickouse_password.empty() || clickhouse_db.empty()) throw std::runtime_error("put the creds in the right place idiot"); + std::string clickhouse_host = config["clickhouse"]["host"].value_or(""); + uint clickhouse_port = config["clickhouse"]["port"].value_or(9000); + if(clickhouse_username.empty() || clickouse_password.empty() || clickhouse_db.empty() || clickhouse_host.empty()) throw std::runtime_error("put the creds in the right place idiot"); spdlog::info("Logging is functional"); + + std::shared_ptr shared_client = std::make_shared(clickhouse::ClientOptions().SetPassword(clickouse_password).SetDefaultDatabase(clickhouse_db).SetUser(clickhouse_username).SetHost(clickhouse_host).SetPort(clickhouse_port)); + spdlog::info("Server connection: {}", shared_client->GetServerInfo().display_name); return 0; }