/
dbutil.h
76 lines (57 loc) · 1.74 KB
/
dbutil.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef DBUTIL_H_
#define DBUTIL_H_
#include <QStringList>
#include "mythexp.h"
#include "mythdbcon.h"
enum MythDBBackupStatus
{
kDB_Backup_Unknown = 0,
kDB_Backup_Failed,
kDB_Backup_Completed,
kDB_Backup_Empty_DB,
kDB_Backup_Disabled
};
/** \class DBUtil
* \brief Aggregates database and DBMS utility functions.
*
* This class allows retrieving or comparing the DBMS server version, and
* backing up the database.
*
* The backup functionality currently requires mysqldump to be installed on
* the system. This may change in the future to allow backups even when
* there is no DB client installation on the system.
*
* \sa HouseKeeper::RunHouseKeeping(void)
*/
class MPUBLIC DBUtil
{
public:
DBUtil();
~DBUtil() { }
QString GetDBMSVersion(void);
int CompareDBMSVersion(int major, int minor=0, int point=0);
MythDBBackupStatus BackupDB(QString &filename);
static bool IsNewDatabase(void);
static bool IsBackupInProgress(void);
static int CountClients(void);
static bool lockSchema(MSqlQuery &);
static void unlockSchema(MSqlQuery &);
static const int kUnknownVersionNumber;
protected:
static bool CreateTemporaryDBConf(
const QString &privateinfo, QString &filename);
private:
bool QueryDBMSVersion(void);
bool ParseDBMSVersion(void);
static QStringList GetTables(void);
QString CreateBackupFilename(QString prefix = "mythconverg",
QString extension = ".sql");
QString GetBackupDirectory();
bool DoBackup(const QString &backupScript, QString &filename);
bool DoBackup(QString &filename);
QString m_versionString;
int m_versionMajor;
int m_versionMinor;
int m_versionPoint;
};
#endif