diff options
author | Cara Salter <cara@devcara.com> | 2023-04-06 17:14:22 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2023-04-06 17:14:22 -0400 |
commit | 555810bedc0cf9d9d954f56b5a2c8c92522ad27f (patch) | |
tree | 0dd37a701fb242fa953c23f2b0a94252fa60762b /include | |
parent | 3a3a1e5345ae8e133fa7800d9fcba2dbb779b8b9 (diff) | |
parent | 7629de5b888bd3d1cdb94dce3ba51cb1e1c2e625 (diff) | |
download | 142bot-555810bedc0cf9d9d954f56b5a2c8c92522ad27f.tar.gz 142bot-555810bedc0cf9d9d954f56b5a2c8c92522ad27f.zip |
Merge branch 'database'
Change-Id: I5f6fb3b64db0585955defdec0fe1ee9555ba89ec
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(); +} |