diff options
author | Cara Salter <cara@devcara.com> | 2023-05-31 20:15:08 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2023-05-31 20:15:08 -0400 |
commit | e09e7825369ec8217456065d31dbbbb992b7f1bb (patch) | |
tree | 37cfbc3b756f75fd6fc446090c18e4ea3464562e /src | |
parent | 31e862b7a4c5c1af9a8b331853d6bc01c49f2816 (diff) | |
download | 142bot-e09e7825369ec8217456065d31dbbbb992b7f1bb.tar.gz 142bot-e09e7825369ec8217456065d31dbbbb992b7f1bb.zip |
meta: Use system libraries to compile0.5
Also: try to make pqxx not use local socket for connections
(unsuccessful)
Change-Id: I351fe1a405a7c204e1276a90da75ab3d32f51bdc
Diffstat (limited to 'src')
-rw-r--r-- | src/bot.cpp | 5 | ||||
-rw-r--r-- | src/db.cpp | 25 |
2 files changed, 6 insertions, 24 deletions
diff --git a/src/bot.cpp b/src/bot.cpp index b1d530c..8c3a84c 100644 --- a/src/bot.cpp +++ b/src/bot.cpp @@ -24,7 +24,10 @@ Bot::Bot(bool devel, dpp::cluster* cluster, char prefix, json &cfg) { std::string token = cfg.value("token", "bad-token"); - this->conn = db::connect(cfg["postgres"]["host"], cfg["postgres"]["user"], cfg["postgres"]["pass"], cfg["postgres"]["database"], cfg["postgres"]["port"]); + this->core->log(dpp::ll_debug, "Attempting DB connection"); + + + this->conn = db::connect(cfg.value("postgres", "postgres://localhost/142bot")); run_database_migrations(); @@ -35,32 +35,11 @@ namespace db { /** * Connects to a postgres database, returns false if error **/ - pqxx::connection connect(const std::string &host, const std::string &user, const std::string &pass, const std::string &db, int port) { + pqxx::connection connect(const std::string cn_s) { std::lock_guard<std::mutex> db_lock(db_mutex); - - std::string cn_s = "postgresql://"; - - if (!user.empty()) { - cn_s = cn_s + user; - } - if (!pass.empty() && !user.empty()) { - cn_s = cn_s + ":" + pass; - } - if ((!user.empty() || !pass.empty())) { - cn_s = cn_s + "@"; - } - - if (!host.empty()) { - cn_s = cn_s + "localhost"; - } - if (port != 0 && !host.empty()) { - cn_s = cn_s + ":" + std::to_string(port); - } - if (!db.empty()) { - cn_s = cn_s + "/" + db; - } + cout << cn_s << endl; sentry_value_t crumb = sentry_value_new_breadcrumb("default", "Started Database Connection"); sentry_value_set_by_key(crumb, "level", sentry_value_new_string("db")); |