From af32ac991f1dd3d9138227436b5759889c1aaf77 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 22 May 2021 14:01:04 +0100 Subject: Move everything into more sensible places --- lib/input/mysqlConn.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/input/mysqlConn.cpp (limited to 'lib/input/mysqlConn.cpp') 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 + +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); + } +} -- cgit v1.2.3