summaryrefslogtreecommitdiff
path: root/lib/input/mysqlConn.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/input/mysqlConn.cpp')
-rw-r--r--lib/input/mysqlConn.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/input/mysqlConn.cpp b/lib/input/mysqlConn.cpp
new file mode 100644
index 0000000..38feb35
--- /dev/null
+++ b/lib/input/mysqlConn.cpp
@@ -0,0 +1,19 @@
+#include "mysqlConn.h"
+#include <stdexcept>
+
+namespace MyGrate::Input {
+ MySQLConn::MySQLConn(const char * const host, const char * const user, const char * const pass, unsigned short port)
+ {
+ mysql_init(this);
+ if (!mysql_real_connect(this, host, user, pass, "", port, nullptr, 0)) {
+ mysql_close(this);
+ throw std::runtime_error("ConnectionError");
+ }
+ mysql_query(this, "SET NAMES utf8");
+ }
+
+ MySQLConn::~MySQLConn()
+ {
+ mysql_close(this);
+ }
+}