Automatic switching to SQLite once MySQL is not available.

This commit is contained in:
Martin Rotter 2016-03-21 07:11:07 +01:00
parent 1f49d2af5b
commit b5dbf6b067
2 changed files with 13 additions and 2 deletions

View File

@ -9,6 +9,7 @@ http://goo.gl/forms/GcvPYgS2a8
Added:
▪ RSS Guard now automatically switches to SQLite backend if MySQL is not available on program startup.
▪ Opened web browser tabs now can be saved. (issue #126)
▪ Added experimental support for tweakable statusbar. (issue #158)
▪ Opening of download manager when new file download starts is now optional. (issue #165)

View File

@ -20,6 +20,7 @@
#include "miscellaneous/iofactory.h"
#include "miscellaneous/application.h"
#include "miscellaneous/textfactory.h"
#include "gui/messagebox.h"
#include <QDir>
#include <QSqlQuery>
@ -638,8 +639,17 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString &connection_
database.setPassword(TextFactory::decrypt(qApp->settings()->value(GROUP(Database), SETTING(Database::MySQLPassword)).toString()));
if (!database.open()) {
qFatal("MySQL database was NOT opened. Delivered error message: '%s'",
qPrintable(database.lastError().text()));
qCritical("MySQL database was NOT opened. Delivered error message: '%s'", qPrintable(database.lastError().text()));
// Now, we will display error warning and return SQLite connection.
// Also, we set the SQLite driver as active one.
qApp->settings()->setValue(GROUP(Database), Database::ActiveDriver, APP_DB_SQLITE_DRIVER);
determineDriver();
MessageBox::show(NULL, QMessageBox::Critical, tr("MySQL database not available"),
tr("%1 cannot use MySQL storage, it is not available. %1 is now switching to SQLite database. Start your MySQL server "
"and make adjustments in application settings.").arg(APP_NAME), QString(), QString());
return connection(objectName(), FromSettings);
}
else {
QSqlQuery query_db(database);