diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-13 01:09:01 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-13 01:09:01 +0100 |
commit | 6b453d0f0f50dccd0333d0d6e8cd0246e86d24a9 (patch) | |
tree | 5ca0f7347d41c1a0634123298963f7a8f9795a7d /lib/input | |
parent | Avoid direct use of runtime_error in PostgreSQL stuff (diff) | |
download | mygrate-6b453d0f0f50dccd0333d0d6e8cd0246e86d24a9.tar.bz2 mygrate-6b453d0f0f50dccd0333d0d6e8cd0246e86d24a9.tar.xz mygrate-6b453d0f0f50dccd0333d0d6e8cd0246e86d24a9.zip |
Create and drop MySQL mock DBs as needed
Diffstat (limited to 'lib/input')
-rw-r--r-- | lib/input/mysqlConn.cpp | 6 | ||||
-rw-r--r-- | lib/input/mysqlConn.h | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/input/mysqlConn.cpp b/lib/input/mysqlConn.cpp index c7705f5..362f9ea 100644 --- a/lib/input/mysqlConn.cpp +++ b/lib/input/mysqlConn.cpp @@ -13,12 +13,12 @@ namespace MyGrate::Input { MySQLErr::MySQLErr(const std::string & when, MYSQL * c) : std::runtime_error(when + ": " + mysql_error(c)) { } - MySQLConn::MySQLConn( - const char * const host, const char * const user, const char * const pass, unsigned short port) : + MySQLConn::MySQLConn(const char * const host, const char * const user, const char * const pass, unsigned short port, + const char * const db) : st_mysql {} { mysql_init(this); - if (!mysql_real_connect(this, host, user, pass, "", port, nullptr, 0)) { + if (!mysql_real_connect(this, host, user, pass, db, port, nullptr, 0)) { mysql_close(this); throw MySQLErr("Connecting", this); } diff --git a/lib/input/mysqlConn.h b/lib/input/mysqlConn.h index d779fd1..dfb408f 100644 --- a/lib/input/mysqlConn.h +++ b/lib/input/mysqlConn.h @@ -19,7 +19,10 @@ namespace MyGrate::Input { public: static constexpr auto paramMode {ParamMode::QMark}; - MySQLConn(const char * const host, const char * const user, const char * const pass, unsigned short port); + MySQLConn(const char * const host, const char * const user, const char * const pass, unsigned short port, + const char * const db = ""); + MySQLConn(const MySQLConn &) = delete; + MySQLConn(MySQLConn &&) = delete; ~MySQLConn(); void query(const char * const) override; |