-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatabase.h
50 lines (47 loc) · 1.12 KB
/
Database.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
#ifndef DATABASE_H
#define DATABASE_H
#include <mysql_driver.h>
#include <mysql_connection.h>
#include <cppconn/statement.h>
#include <cppconn/resultset.h>
#include <cppconn/prepared_statement.h>
#include <iostream>
#include <string>
#include <nlohmann/json.hpp>
#include <error.h>
#include <vector>
#include <set>
#include <algorithm>
#include "include/crow_all.h"
using json = nlohmann::json;
struct Item
{
std::string name;
std::vector<std::string> tags;
std::string summary;
std::string url;
Item(){};
Item(std::string name, std::vector<std::string> tags, std::string summary)
{
this->name = name;
this->tags = tags;
this->summary = summary;
this->url = url;
}
} typedef Item;
class Database
{
public:
Database();
~Database();
std::vector<Item> get(std::string query = "");
std::vector<std::string> split(const std::string &s, char delimiter);
std::string buildQuery(const std::vector<std::string> &words);
void insert(Item newItem);
private:
sql::mysql::MySQL_Driver *driver;
sql::Connection *con;
sql::ResultSet *res;
Item item;
};
#endif