-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMySQLInterface.h
More file actions
39 lines (31 loc) · 975 Bytes
/
Copy pathMySQLInterface.h
File metadata and controls
39 lines (31 loc) · 975 Bytes
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 __MYSQL_INTERFACE_H__
#define __MYSQL_INTERFACE_H__
#include "winsock.h"
#include <iostream>
#include <string>
#include "mysql.h"
#include <vector>
#include <string>
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "libmysql.lib")
using namespace std;
class MySQLInterface
{
public:
MySQLInterface();
virtual ~MySQLInterface();
bool connectMySQL(char* server, char* username, char* password, char* database,int port);
bool createDatabase(std::string& dbname);
bool createdbTable(const std::string& query);
void errorIntoMySQL();
bool writeDataToDB(string queryStr);
bool getDatafromDB(string queryStr, std::vector<std::vector<std::string> >& data);
void closeMySQL();
public:
int errorNum; //错误代号
const char* errorInfo; //错误提示
private:
MYSQL mysqlInstance; //MySQL对象,必备的一个数据结构
MYSQL_RES *result; //用于存放结果 建议用char* 数组将此结果转存
};
#endif