Do not create empty database file when it does not exist
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
|
||||
// define symbol printqueries if all queries should be printed to the console
|
||||
// #define printqueries
|
||||
@@ -55,6 +56,9 @@ TraceDB::TraceDB(const QString& path, bool openExisting)
|
||||
{
|
||||
this->pathToDB = path;
|
||||
|
||||
if (!std::filesystem::exists(path.toStdString()))
|
||||
throw std::runtime_error("Database file does not exist!");
|
||||
|
||||
database = QSqlDatabase::database(path);
|
||||
if (database.isValid() && database.isOpen())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user