diff options
author | Cara Salter <cara@devcara.com> | 2023-04-06 15:45:39 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2023-04-06 17:11:52 -0400 |
commit | 7629de5b888bd3d1cdb94dce3ba51cb1e1c2e625 (patch) | |
tree | 0dd37a701fb242fa953c23f2b0a94252fa60762b /include | |
parent | b66bf922cc2d8eb3a623d1f776ab6a144832f587 (diff) | |
download | 142bot-7629de5b888bd3d1cdb94dce3ba51cb1e1c2e625.tar.gz 142bot-7629de5b888bd3d1cdb94dce3ba51cb1e1c2e625.zip |
pg: Add postgres support
Supports migrations
Change-Id: Ifca8358d4f57a4b417f1d972e400e98767e01bb5
Diffstat (limited to 'include')
-rw-r--r-- | include/142bot/bot.hpp | 7 | ||||
-rw-r--r-- | include/142bot/db.hpp | 37 |
2 files changed, 42 insertions, 2 deletions
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 <dpp/snowflake.h> #include <dpp/user.h> #include <dpp/dpp.h> +#include <pqxx/pqxx> #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 <vector> +#include <map> +#include <string> +#include <variant> +#include <pqxx/pqxx> + + +namespace db { + typedef std::map<std::string, std::string> row; + typedef std::vector<row> resultset; + + typedef std::vector<std::variant<float, std::string, uint64_t, int64_t, bool, int32_t, uint32_t, double>> 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(); +} |