diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-05-22 14:01:04 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-05-22 14:01:04 +0100 |
commit | af32ac991f1dd3d9138227436b5759889c1aaf77 (patch) | |
tree | 5af019a48d06ee943e3debac0eff3c0be073cc8f /lib/input/mysqlConn.cpp | |
parent | Add test file for odds and ends (diff) | |
download | mygrate-af32ac991f1dd3d9138227436b5759889c1aaf77.tar.bz2 mygrate-af32ac991f1dd3d9138227436b5759889c1aaf77.tar.xz mygrate-af32ac991f1dd3d9138227436b5759889c1aaf77.zip |
Move everything into more sensible places
Diffstat (limited to 'lib/input/mysqlConn.cpp')
-rw-r--r-- | lib/input/mysqlConn.cpp | 19 |
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); + } +} |