Fledge
An open source edge computing platform for industrial users
sqlite_common.h
1
#ifndef _COMMON_CONNECTION_H
2
#define _COMMON_CONNECTION_H
3
4
#include <sql_buffer.h>
5
#include <iostream>
6
#include <sqlite3.h>
7
#include "rapidjson/document.h"
8
#include "rapidjson/writer.h"
9
#include "rapidjson/stringbuffer.h"
10
#include "rapidjson/error/error.h"
11
#include "rapidjson/error/en.h"
12
#include <string>
13
#include <map>
14
#include <stdarg.h>
15
#include <stdlib.h>
16
#include <sstream>
17
#include <logger.h>
18
#include <time.h>
19
#include <unistd.h>
20
#include <chrono>
21
#include <thread>
22
#include <atomic>
23
#include <condition_variable>
24
#include <sys/time.h>
25
26
#define _DB_NAME "/fledge.db"
27
#define READINGS_DB_NAME_BASE "readings"
28
29
#define DB_CONFIGURATION "PRAGMA busy_timeout = 5000; PRAGMA cache_size = -4000; PRAGMA journal_mode = WAL; PRAGMA secure_delete = off; PRAGMA journal_size_limit = 4096000;"
30
31
#define LEN_BUFFER_DATE 100
32
#define F_TIMEH24_S "%H:%M:%S"
33
#define F_DATEH24_S "%Y-%m-%d %H:%M:%S"
34
#define F_DATEH24_M "%Y-%m-%d %H:%M"
35
#define F_DATEH24_H "%Y-%m-%d %H"
36
// This is the default datetime format in Fledge: 2018-05-03 18:15:00.622
37
#define F_DATEH24_MS "%Y-%m-%d %H:%M:%f"
38
// Format up to seconds
39
#define F_DATEH24_SEC "%Y-%m-%d %H:%M:%S"
40
#define SQLITE3_NOW "strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime')"
41
// The default precision is milliseconds, it adds microseconds and timezone
42
#define SQLITE3_NOW_READING "strftime('%Y-%m-%d %H:%M:%f000+00:00', 'now')"
43
#define SQLITE3_FLEDGE_DATETIME_TYPE "DATETIME"
44
45
#define STORAGE_PURGE_RETAIN_ANY 0x0001U
46
#define STORAGE_PURGE_RETAIN_ALL 0x0002U
47
#define STORAGE_PURGE_SIZE 0x0004U
48
49
static
std::map<std::string, std::string> sqliteDateFormat = {
50
{
"HH24:MI:SS"
,
51
F_TIMEH24_S},
52
{
"YYYY-MM-DD HH24:MI:SS.MS"
,
53
F_DATEH24_MS},
54
{
"YYYY-MM-DD HH24:MI:SS"
,
55
F_DATEH24_S},
56
{
"YYYY-MM-DD HH24:MI"
,
57
F_DATEH24_M},
58
{
"YYYY-MM-DD HH24"
,
59
F_DATEH24_H},
60
{
""
,
""
}
61
};
62
#endif
C
plugins
storage
sqlite
common
include
sqlite_common.h
Generated by
1.8.13