aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.h
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2023-04-30 18:30:36 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2023-04-30 18:30:36 -0400
commit3565aad630864ecdbe53fdaa501ea708555b3c7c (patch)
treec743e4ad0bad39ebdb2f514c7cc52d34a257ebbe /SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.h
parent1fdc150116cad39aae5c5da407c3312b47a59e3a (diff)
New upstream version 3.4.4+dfsg.upstream/3.4.4+dfsg
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.h')
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.h b/SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.h
new file mode 100644
index 0000000..fbca301
--- /dev/null
+++ b/SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.h
@@ -0,0 +1,43 @@
+#ifndef SQLFILEEXECUTOR_H
+#define SQLFILEEXECUTOR_H
+
+#include "coreSQLiteStudio_global.h"
+#include <QObject>
+#include <QTextStream>
+
+class Db;
+
+class API_EXPORT SqlFileExecutor : public QObject
+{
+ Q_OBJECT
+
+ public:
+ explicit SqlFileExecutor(QObject *parent = nullptr);
+ void execSqlFromFile(Db* db, const QString& filePath, bool ignoreErrors, QString codec, bool async = true);
+ bool isExecuting() const;
+
+ private:
+ bool execQueryFromFile(Db* db, const QString& sql);
+ void execInThread();
+ void handleExecutionResults(Db* db, int executed, int attemptedExecutions, bool ok, bool ignoreErrors, int millis);
+ QList<QPair<QString, QString>> executeFromStream(QTextStream& stream, int& executed, int& attemptedExecutions, bool& ok, qint64 fileSize);
+ bool shouldSkipQuery(const QString& sql);
+
+ QAtomicInt executionInProgress = 0;
+ Db* db = nullptr;
+ bool fkWasEnabled = true;
+ bool ignoreErrors = false;
+ QString codec;
+ QString filePath;
+
+ public slots:
+ void stopExecution();
+
+ signals:
+ void schemaNeedsRefreshing(Db* db);
+ void updateProgress(int value);
+ void execEnded();
+ void execErrors(const QList<QPair<QString, QString>>& errors, bool rolledBack);
+};
+
+#endif // SQLFILEEXECUTOR_H