Do not create empty database file when it does not exist

This commit is contained in:
2025-02-26 09:28:36 +01:00
parent e691d46a55
commit 5b76e52cd4

View File

@@ -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())
{