DBUtil Class Reference

#include <dbutil.h>

List of all members.


Detailed Description

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.

See also:
HouseKeeper::RunHouseKeeping(void)

Definition at line 20 of file dbutil.h.


Public Member Functions

 DBUtil ()
 Constructs the DBUtil object.
 ~DBUtil ()
QString GetDBMSVersion (void)
 Returns the QString version name of the DBMS or QString::null in the event of an error.
int CompareDBMSVersion (int major, int minor=0, int point=0)
 Compares the version of the active DBMS with the provided version.
bool BackupDB (QString &filename)

Static Public Member Functions

static bool IsBackupInProgress (void)

Static Public Attributes

static const int kUnknownVersionNumber = INT_MIN

Private Member Functions

bool QueryDBMSVersion (void)
 Reads and returns the QString version name from the DBMS or returns QString::null in the event of an error.
bool ParseDBMSVersion (void)
 Parses m_versionString to find the major, minor, and point version.
QStringList GetTables (void)
 Retrieves a list of tables from the database.
QString CreateBackupFilename (QString prefix="mythconverg", QString extension=".sql")
 Creates a filename to use for the filename.
QString GetBackupDirectory ()
 Determines the appropriate path for the database backup.
bool DoBackup (QString &filename)

Private Attributes

QString m_versionString
int m_versionMajor
int m_versionMinor
int m_versionPoint

Constructor & Destructor Documentation

DBUtil::DBUtil ( void   ) 

Constructs the DBUtil object.

Definition at line 26 of file dbutil.cpp.

DBUtil::~DBUtil (  )  [inline]

Definition at line 24 of file dbutil.h.


Member Function Documentation

QString DBUtil::GetDBMSVersion ( void   ) 

Returns the QString version name of the DBMS or QString::null in the event of an error.

Definition at line 36 of file dbutil.cpp.

Referenced by UpgradeTVDatabaseSchema().

int DBUtil::CompareDBMSVersion ( int  major,
int  minor = 0,
int  point = 0 
)

Compares the version of the active DBMS with the provided version.

Returns negative, 0, or positive if the active DBMS version is less than, equal to, or greater than the provided version or returns DBUtil::kUnknownVersionNumber if the version cannot be determined.

Parameters:
major The major version number (i.e. 5 in "5.0.22")
minor The minor version number (i.e. 0 in "5.0.22")
point The point version number (i.e. 22 in "5.0.22")
Returns:
negative, 0, or positive or DBUtil::kUnknownVersionNumber for error

Definition at line 55 of file dbutil.cpp.

Referenced by GetTables(), and UpgradeTVDatabaseSchema().

bool DBUtil::BackupDB ( QString &  filename  ) 

Definition at line 163 of file dbutil.cpp.

Referenced by UpgradeTVDatabaseSchema().

bool DBUtil::IsBackupInProgress ( void   )  [static]

Definition at line 77 of file dbutil.cpp.

Referenced by CheckSchemaVersion().

bool DBUtil::QueryDBMSVersion ( void   )  [private]

Reads and returns the QString version name from the DBMS or returns QString::null in the event of an error.

Definition at line 398 of file dbutil.cpp.

Referenced by GetDBMSVersion(), and ParseDBMSVersion().

bool DBUtil::ParseDBMSVersion ( void   )  [private]

Parses m_versionString to find the major, minor, and point version.

Definition at line 427 of file dbutil.cpp.

Referenced by CompareDBMSVersion().

QStringList DBUtil::GetTables ( void   )  [private]

Retrieves a list of tables from the database.

The function tries to ensure that the list contains only tables and no views. However, for MySQL 5.0.1, the list will also contain any views defined in the database.

Returns:
QStringList containing table names

Definition at line 203 of file dbutil.cpp.

QString DBUtil::CreateBackupFilename ( QString  prefix = "mythconverg",
QString  extension = ".sql" 
) [private]

Creates a filename to use for the filename.

The filename is a concatenation of the given prefix, a hyphen, the current date/time, and the extension.

Parameters:
prefix The prefix (i.e. a database name) which should appear before the date/time
extension The extension to use for the file, including a dot, if desired
Returns:
QString name

Definition at line 248 of file dbutil.cpp.

Referenced by DoBackup().

QString DBUtil::GetBackupDirectory ( void   )  [private]

Determines the appropriate path for the database backup.

The function requests the special "DB Backups" storage group. In the event the group is not defined, the StorageGroup will fall back to using the "Default" group. For users upgrading from version 0.20 or before (which do not support Storage Groups), the StorageGroup will fall back to using the old RecordFilePrefix.

Definition at line 264 of file dbutil.cpp.

Referenced by DoBackup().

bool DBUtil::DoBackup ( QString &  filename  )  [private]

Definition at line 294 of file dbutil.cpp.

Referenced by BackupDB().


Member Data Documentation

const int DBUtil::kUnknownVersionNumber = INT_MIN [static]

Definition at line 33 of file dbutil.h.

Referenced by CompareDBMSVersion(), and UpgradeTVDatabaseSchema().

QString DBUtil::m_versionString [private]

Definition at line 47 of file dbutil.h.

Referenced by GetDBMSVersion(), ParseDBMSVersion(), and QueryDBMSVersion().

int DBUtil::m_versionMajor [private]

Definition at line 49 of file dbutil.h.

Referenced by CompareDBMSVersion(), and ParseDBMSVersion().

int DBUtil::m_versionMinor [private]

Definition at line 50 of file dbutil.h.

Referenced by CompareDBMSVersion(), and ParseDBMSVersion().

int DBUtil::m_versionPoint [private]

Definition at line 51 of file dbutil.h.

Referenced by CompareDBMSVersion(), and ParseDBMSVersion().


The documentation for this class was generated from the following files:

Generated on Sat Dec 18 05:16:01 2010 for MythTV by  doxygen 1.5.5