forked from RichA0x00/WMR100-MySQL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql.h
96 lines (75 loc) · 2.31 KB
/
mysql.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#define TABLE_TEMP "create table TEMP ( \
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, \
timestamp TIMESTAMP DEFAULT NOW(), \
sensor TINYINT UNSIGNED ZEROFILL, \
smile TINYINT UNSIGNED ZEROFILL, \
trend char(1), \
temp float, \
humidity TINYINT UNSIGNED ZEROFILL, \
dewpoint float \
);"
#define TABLE_MAP_TEMP "(sensor, smile, trend, temp, humidity, dewpoint)"
#define TABLE_RAIN "create table RAIN ( \
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, \
timestamp TIMESTAMP DEFAULT NOW(), \
sensor TINYINT UNSIGNED ZEROFILL, \
power TINYINT UNSIGNED ZEROFILL, \
rate TINYINT UNSIGNED ZEROFILL, \
hour_total float ZEROFILL, \
day_total float ZEROFILL, \
all_total float ZEROFILL, \
since VARCHAR(20) \
);"
#define TABLE_MAP_RAIN "(sensor, power, rate, hour_total, day_total, all_total, since)"
#define TABLE_PRESSURE "create table PRESSURE ( \
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, \
timestamp TIMESTAMP DEFAULT NOW(), \
pressure TINYINT UNSIGNED ZEROFILL, \
forecast TINYINT UNSIGNED ZEROFILL, \
altpressure TINYINT UNSIGNED ZEROFILL, \
altforecast TINYINT UNSIGNED ZEROFILL \
);"
#define TABLE_MAP_PRESSURE "(pressure, forecast, altpressure, altforecast)"
#define TABLE_UV "create table UV ( \
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, \
timestamp TIMESTAMP DEFAULT NOW(), \
type VARCHAR(10) \
);"
#define TABLE_MAP_UV "(type)"
#define TABLE_WIND "create table WIND( \
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, \
timestamp TIMESTAMP DEFAULT NOW(), \
power TINYINT UNSIGNED ZEROFILL, \
dir VARCHAR(5), \
speed TINYINT UNSIGNED ZEROFILL, \
avgspeed TINYINT UNSIGNED ZEROFILL \
);"
#define TABLE_MAP_WIND "(power, dir, speed, avgspeed)"
#define TABLE_CLOCK "create table CLOCK ( \
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, \
timestamp TIMESTAMP DEFAULT NOW(), \
clock VARCHAR(20), \
powered TINYINT UNSIGNED ZEROFILL, \
battery TINYINT UNSIGNED ZEROFILL, \
rf TINYINT ZEROFILL, \
level TINYINT ZEROFILL \
);"
#define TABLE_MAP_CLOCK "(clock, powered, battery, rf, level)"
#define BIGBUFFER 10000
/*
INPUT: MySQL Handler
Outputs to STDERR - Errno and message
*/
void mysql_print_error(MYSQL *);
/*
INPUT
hostname
username
password
database name
port number
socket name
NULL == Default
Returns pointer to MySQL handler or it exits the program
*/
MYSQL *mysql_connect(char *, char *, char *, char *, unsigned int, char *,unsigned int);