-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsql_common.h
48 lines (36 loc) · 1.27 KB
/
sql_common.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
#ifndef SQL_COMMON_H
#define SQL_COMMON_H
#endif // SQL_COMMON_H
#define DB_SQLTYPE_SQLITE "SQLITE"
#define DB_SQLTYPE_MYSQL "MYSQL"
#define DB_SQLTYPE_SQLSERVER "SQLSERVER"
// Constant
const int MYSQL_DEFAULTPORT_C = 3306;
const QString MYSQL_DEFAULTUSER_C = "root";
/*#define ERROR_DB QString::fromStdString(__FILE__) + ", " + QString::fromStdString(__FUNCTION__) + ", line " + QString::number(__LINE__) + ": " + db.lastError().text()
#define ERROR_QUERY QString::fromStdString(__FILE__) + ", " + QString::fromStdString(__FUNCTION__) + ", line " + QString::number(__LINE__) + ": " + query.lastError().text() */
enum class DBTypes_E {
MYSQL,
SQLite,
SQLServer
};
static QMap<DBTypes_E, QString> DBTypesToStr_Map {
{ DBTypes_E::MYSQL, DB_SQLTYPE_MYSQL },
{ DBTypes_E::SQLite, DB_SQLTYPE_SQLITE },
{ DBTypes_E::SQLServer, DB_SQLTYPE_SQLSERVER },
};
static QMap<QString, DBTypes_E> StrToDBTypes_Map {
{ DB_SQLTYPE_MYSQL, DBTypes_E::MYSQL },
{ DB_SQLTYPE_SQLITE, DBTypes_E::SQLite },
{ DB_SQLTYPE_SQLSERVER, DBTypes_E::SQLServer },
};
// Structure
struct DBConfig {
QString appPath = "";
DBTypes_E type = DBTypes_E::MYSQL;
QString host = "localhost";
int port = MYSQL_DEFAULTPORT_C;
QString name = "";
QString user = MYSQL_DEFAULTUSER_C;
QString pass;
};