Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlDatabase and local Sqlite 3. Abnormal application stop.
Forum Updated to NodeBB v4.3 + New Features

QSqlDatabase and local Sqlite 3. Abnormal application stop.

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bogong
    wrote on 12 Sept 2019, 08:25 last edited by bogong 9 Dec 2019, 08:27
    #1

    Hello!
    I am trying to find information about handling Sqlite data restore issues if something goes wrong with application at time of writing to DB locally. For example: application writing into DB but occasionally the electricity switched off at the middle of writing and the questions:

    • what will be happening in Sqlite?
    • is there any documentation about restoring Sqlite after crash?
    • is there something special in Qt for this case?

    For this topic I found this https://stackoverflow.com/questions/1452790/will-database-file-of-sqlite3-be-damaged-when-suddenly-power-off-or-os-crash

    J 1 Reply Last reply 12 Sept 2019, 11:07
    0
    • B bogong
      12 Sept 2019, 08:25

      Hello!
      I am trying to find information about handling Sqlite data restore issues if something goes wrong with application at time of writing to DB locally. For example: application writing into DB but occasionally the electricity switched off at the middle of writing and the questions:

      • what will be happening in Sqlite?
      • is there any documentation about restoring Sqlite after crash?
      • is there something special in Qt for this case?

      For this topic I found this https://stackoverflow.com/questions/1452790/will-database-file-of-sqlite3-be-damaged-when-suddenly-power-off-or-os-crash

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 12 Sept 2019, 11:07 last edited by jsulm 9 Dec 2019, 11:08
      #2

      @bogong SQLite supports transactions, that means: if a write operation was not committed (because your app crashed or what ever) your database will be unchanged.
      "what will be happening in Sqlite?" see above
      "is there any documentation about restoring Sqlite after crash?" - no idea, you should check SQLite documentation, has nothing to do with Qt. Just search on the Web. For example https://www.recoveryandmanagement.com/repair-sqlite-database-manually/
      "is there something special in Qt for this case?" - I don't think so, because there is no need to have something special in Qt for this.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply 12 Sept 2019, 11:58
      1
      • J jsulm
        12 Sept 2019, 11:07

        @bogong SQLite supports transactions, that means: if a write operation was not committed (because your app crashed or what ever) your database will be unchanged.
        "what will be happening in Sqlite?" see above
        "is there any documentation about restoring Sqlite after crash?" - no idea, you should check SQLite documentation, has nothing to do with Qt. Just search on the Web. For example https://www.recoveryandmanagement.com/repair-sqlite-database-manually/
        "is there something special in Qt for this case?" - I don't think so, because there is no need to have something special in Qt for this.

        B Offline
        B Offline
        bogong
        wrote on 12 Sept 2019, 11:58 last edited by
        #3

        @jsulm thx for reply. I know about transaction. I mean about db-file physically (my precautions might be overkill, but on other DB Engines I've seen corrupted file physically because of switched off electricity).

        J 1 Reply Last reply 12 Sept 2019, 12:42
        0
        • B bogong
          12 Sept 2019, 11:58

          @jsulm thx for reply. I know about transaction. I mean about db-file physically (my precautions might be overkill, but on other DB Engines I've seen corrupted file physically because of switched off electricity).

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 12 Sept 2019, 12:42 last edited by
          #4

          @bogong This is outside of Qts scope. You should search for this functionality in SQLite project and on the Web in general.
          Also, since SQLite is file based you can easily create copies of the DB file and restore older one if the current gets corrupted.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          B 1 Reply Last reply 13 Sept 2019, 12:06
          3
          • J jsulm
            12 Sept 2019, 12:42

            @bogong This is outside of Qts scope. You should search for this functionality in SQLite project and on the Web in general.
            Also, since SQLite is file based you can easily create copies of the DB file and restore older one if the current gets corrupted.

            B Offline
            B Offline
            bogong
            wrote on 13 Sept 2019, 12:06 last edited by bogong
            #5

            @jsulm Ok. I know how to perform backup on SQlite (here everything described):

            • Lock DB
            • Copy DB physical file somewhere
            • Unlock DB

            It's very similar to many others SQL DB Engines

            I've been seeking something that already is in Qt Distribution because of SQlite plugin in Qt. Seems nothing changed for last 5 years. For me it's very curious because data backup point - is where I am always starting developing of any storage and it's doesn't matter on which language (but it's only my own opinion).

            J 1 Reply Last reply 13 Sept 2019, 12:18
            0
            • B bogong
              13 Sept 2019, 12:06

              @jsulm Ok. I know how to perform backup on SQlite (here everything described):

              • Lock DB
              • Copy DB physical file somewhere
              • Unlock DB

              It's very similar to many others SQL DB Engines

              I've been seeking something that already is in Qt Distribution because of SQlite plugin in Qt. Seems nothing changed for last 5 years. For me it's very curious because data backup point - is where I am always starting developing of any storage and it's doesn't matter on which language (but it's only my own opinion).

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 13 Sept 2019, 12:18 last edited by
              #6

              @bogong said in QSqlDatabase and local Sqlite 3. Abnormal application stop.:

              Lock DB
              Copy DB physical file somewhere
              Unlock DB

              You can already do this with Qt

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              B 1 Reply Last reply 13 Sept 2019, 14:22
              0
              • J jsulm
                13 Sept 2019, 12:18

                @bogong said in QSqlDatabase and local Sqlite 3. Abnormal application stop.:

                Lock DB
                Copy DB physical file somewhere
                Unlock DB

                You can already do this with Qt

                B Offline
                B Offline
                bogong
                wrote on 13 Sept 2019, 14:22 last edited by bogong
                #7

                @jsulm Is there backup-module implemented in-box for Qt where I only define directory and file for backup?

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 13 Sept 2019, 14:29 last edited by
                  #8

                  @bogong said in QSqlDatabase and local Sqlite 3. Abnormal application stop.:

                  Is there backup-module implemented in-box for Qt

                  No, I don't see a reason why it should be in Qt. Doing a simple file copy every n minutes isn't really that hard...

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  B 1 Reply Last reply 13 Sept 2019, 14:37
                  0
                  • C Christian Ehrlicher
                    13 Sept 2019, 14:29

                    @bogong said in QSqlDatabase and local Sqlite 3. Abnormal application stop.:

                    Is there backup-module implemented in-box for Qt

                    No, I don't see a reason why it should be in Qt. Doing a simple file copy every n minutes isn't really that hard...

                    B Offline
                    B Offline
                    bogong
                    wrote on 13 Sept 2019, 14:37 last edited by
                    #9

                    @christian-ehrlicher You are very wrong about "very simple", and this is why:

                    • When you making DB lock you should care about cache where data preliminary storing for being added into when unlock, especially for embedded and mobile device if they working like data aggregator.
                    • If the data structure of the DB complicated and contain few related DB's you have to cary about the structure first
                    • The correct way for complex data might be not enough only physical copying files, it might to take time and load heavily - mean need to be implemented in thread within defined priority and if there are not enough battery you will kill backup and DB.
                    • etc

                    It's only few issues that I've been handling on SQlite.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on 13 Sept 2019, 16:43 last edited by
                      #10

                      When you really care about such a data integrity then SQLite is for sure not the correct choice...

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      B 1 Reply Last reply 14 Sept 2019, 21:30
                      0
                      • C Christian Ehrlicher
                        13 Sept 2019, 16:43

                        When you really care about such a data integrity then SQLite is for sure not the correct choice...

                        B Offline
                        B Offline
                        bogong
                        wrote on 14 Sept 2019, 21:30 last edited by bogong
                        #11

                        @christian-ehrlicher In some cases it's only one way ... first of any - license ... That why I am asking and doing such complexity.

                        1 Reply Last reply
                        0

                        1/11

                        12 Sept 2019, 08:25

                        • Login

                        • Login or register to search.
                        1 out of 11
                        • First post
                          1/11
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved