File: sqlfileexecutor.h

package info (click to toggle)
sqlitestudio 3.4.17-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 61,252 kB
  • sloc: ansic: 403,094; cpp: 122,803; yacc: 2,619; java: 992; tcl: 495; sh: 440; xml: 426; makefile: 19
file content (43 lines) | stat: -rw-r--r-- 1,388 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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; // See comment about fkWasEnabled in cpp file.
        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