-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.h
40 lines (33 loc) · 814 Bytes
/
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
#ifndef DATABASE_H
#define DATABASE_H
#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QFile>
#include <QDebug>
#include <QSqlError>
#include <QSqlRecord>
#include <QString>
#define Database_HOSTNAME "localhost"
#define Database_NAME "mydatabase.db"
#define TABLE "users"
class Database : public QObject
{
Q_OBJECT
public:
explicit Database(QObject *parent = nullptr);
~Database();
void connectToDatabase();
private:
QSqlDatabase db;
bool openDatabase();
bool restorDatabase();
bool closeDatabase();
bool createTable();
signals:
public slots:
bool insertIntoTable(const QVariantList& data);
bool insertIntoTable(const QString& fname, const QString& sname, const QString& nik);
bool removeRecord(const int id);
};
#endif // DATABASE_H