-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdbase.h
49 lines (37 loc) · 1.15 KB
/
dbase.h
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
40
41
42
43
44
45
46
47
48
49
#ifndef ESCADA_CORE_DBASE_H
#define ESCADA_CORE_DBASE_H
#define MAX_QUERY_LENGTH 300
#include <mysql/mysql.h>
#include <stdint.h>
#include "const.h"
#include <string.h>
class DBase {
private:
MYSQL *mysql = nullptr;
char fields[32][64];
uint8_t nFields;
public:
char driver[MAX_STR];
char host[MAX_STR];
char user[MAX_STR];
char pass[MAX_STR];
char database[MAX_STR];
DBase() {
memset(driver, 0, MAX_STR);
memset(host, 0, MAX_STR);
memset(user, 0, MAX_STR);
memset(pass, 0, MAX_STR);
memset(database, 0, MAX_STR);
}
int openConnection(); //connect to the database
int disconnect(); //disconnect from the database
MYSQL_RES *sqlexec(const char *query);
char *GetChannel(char *measureTypeUuid, uint16_t channel, char *deviceUuid);
bool StoreData(uint16_t type, uint16_t status, double value, char *data, char *channelUuid);
int8_t makeFieldsList(MYSQL_RES *res);
int8_t getFieldIndex(const char *fieldName);
char *getFieldValue(MYSQL_ROW row, const char *fieldName);
bool isError();
const char *getErrorString();
};
#endif //ESCADA_CORE_DBASE_H