summaryrefslogtreecommitdiff
path: root/lib/input/mysqlConn.h
blob: bd53616eb7dfc472e7f055aae15f5ad4cc1f12cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef MYGRATE_INPUT_MYSQLCONN_H
#define MYGRATE_INPUT_MYSQLCONN_H

#include <cstddef>
#include <dbConn.h>
#include <initializer_list>
#include <mysql.h>

namespace MyGrate {
	class DbValue;
}
namespace MyGrate::Input {
	class MySQLErr : public std::runtime_error {
	public:
		MySQLErr(const std::string & when, MYSQL *);
	};

	class MySQLConn : public MYSQL, public DbConn {
	public:
		static constexpr auto paramMode {ParamMode::QMark};

		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;
		void query(const char * const q, const std::initializer_list<DbValue> &) override;

		DbPrepStmtPtr prepare(const char * const, std::size_t) override;

		void beginTx() override;
		void commitTx() override;
		void rollbackTx() override;
	};
}

#endif