-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.h
More file actions
36 lines (33 loc) · 885 Bytes
/
database.h
File metadata and controls
36 lines (33 loc) · 885 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
#ifndef DATABASE_H
#define DATABASE_H
#include <string>
#include <memory>
#include <mutex>
#include <cstdlib>
#include "Poco/Data/SessionPool.h"
using namespace Poco::Data;
enum DB_TYPE {
POSTGRESQL = 0,
MYSQL = 1,
SQLITE = 2,
};
class CDatabase
{
public:
CDatabase();
~CDatabase();
public:
static void Connect(DB_TYPE db_type, const std::string &sdb_name=std::getenv("DB_NAME"), const std::string &sdb_user=std::getenv("DB_USER"), const std::string &sdb_password=std::getenv("DB_PASSWORD"), const std::string &sdb_host=std::getenv("DB_HOST"), const std::string& sdb_port=std::getenv("DB_PORT"));
protected:
static std::mutex m_mu;
static std::unique_ptr<SessionPool> m_pool;
Session m_sess;
// std::unique_ptr<Session> m_sess;
public:
void Begin();
void Commit();
void Rollback();
public:
void test();
};
#endif // DATABASE_H