aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/142bot/bot.hpp7
-rw-r--r--include/142bot/db.hpp37
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 &parameters);
+ const std::string& error();
+}