From 7629de5b888bd3d1cdb94dce3ba51cb1e1c2e625 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Thu, 6 Apr 2023 15:45:39 -0400 Subject: pg: Add postgres support Supports migrations Change-Id: Ifca8358d4f57a4b417f1d972e400e98767e01bb5 --- include/142bot/bot.hpp | 7 +++++-- include/142bot/db.hpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 include/142bot/db.hpp (limited to 'include') diff --git a/include/142bot/bot.hpp b/include/142bot/bot.hpp index 49aa956..a422416 100644 --- a/include/142bot/bot.hpp +++ b/include/142bot/bot.hpp @@ -1,6 +1,7 @@ #include #include #include +#include #ifndef BOT_HPP @@ -8,9 +9,11 @@ class Module; class ModuleLoader; class Bot { + pqxx::connection conn; bool dev; dpp::snowflake owner_id; - +private: + bool run_database_migrations(); public: class dpp::cluster * core; /* The bot's user from the ready event */ @@ -18,7 +21,7 @@ public: Bot(bool development, dpp::cluster* cluster); //virtual ~Bot(); - + void set_owner_id(dpp::snowflake id); dpp::snowflake get_owner_id(); diff --git a/include/142bot/db.hpp b/include/142bot/db.hpp new file mode 100644 index 0000000..69245d3 --- /dev/null +++ b/include/142bot/db.hpp @@ -0,0 +1,37 @@ +/* + * ===================================================================================== + * + * Filename: db.hpp + * + * Description: + * + * Version: 1.0 + * Created: 04/06/2023 11:38:35 AM + * Revision: none + * Compiler: gcc + * + * Author: Cara Salter (muirrum), cara@devcara.com + * Organization: Worcester Polytechnic Institute + * + * ===================================================================================== + */ + +#pragma once +#include +#include +#include +#include +#include + + +namespace db { + typedef std::map row; + typedef std::vector resultset; + + typedef std::vector> paramlist; + + pqxx::connection connect(const std::string &host, const std::string &user, const std::string &pass, const std::string &db, int port); + bool close(); + resultset query(const std::string &format, const paramlist ¶meters); + const std::string& error(); +} -- cgit v1.2.3