forked from sesorov/PostgresGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBManager.h
38 lines (34 loc) · 1.13 KB
/
DBManager.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
#pragma once
#include <QString>
#include <QSqlDatabase>
#include <QVector>
#include <QSqlQuery>
#include <qsqlerror.h>
#include <qstandarditemmodel.h>
#include <QMap>
#include <qjsonobject>
class DBManager
{
QString databaseName;
QString tableName;
QJsonObject user;
public:
DBManager(QString databaseName, QString tableName, QJsonObject user) : databaseName(databaseName), tableName(tableName), user(user) {}
DBManager() {};
// General DB management options
void createUser(QString username, QString password, bool admin);
bool clean();
bool create();
void createTable();
bool drop();
// Basic operations
bool insert(QString name, QString surname, QString phone);
bool remove(QString id = NULL, QString name = NULL, QString surname = NULL, QString phone = NULL);
bool update(QString id = NULL, QString name = NULL, QString surname = NULL, QString phone = NULL);
QStandardItemModel* search(QString id = NULL, QString name = NULL, QString surname = NULL, QString phone = NULL);
QStandardItemModel* getAll();
// Other
QSqlDatabase getDatabase(QString customDBName = NULL);
QString getDatabaseName();
void setDefaultProcedures();
};