blob: 6c00628863d3eabce8b09c4b24e62d0370a7595b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#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) :
st_mysql {}
{
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);
}
}
|