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. How to restore a backed up sqlite database ?
Forum Updated to NodeBB v4.3 + New Features

How to restore a backed up sqlite database ?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 877 Views 1 Watching
  • 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.
  • Ramkumar MohanR Offline
    Ramkumar MohanR Offline
    Ramkumar Mohan
    wrote on last edited by
    #1

    Hi,

        QString strError;
        QString strPathSqlite;
        QString fileName = "Dump.sql";
        QProcess p;
        p.setStandardOutputFile(fileName);
        p.setWorkingDirectory("/home/pi/git/");
        strPathSqlite = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/sqlite3");
        strPathSqlite.replace("\\","\\\\");
        p.start(strPathSqlite + " /home/pi/bc.db < " + fileName);
        qDebug()<<strPathSqlite;
        qDebug()<<fileName;
        if (!p.waitForStarted() || !p.waitForFinished(-1) || (p.exitStatus() != QProcess::NormalExit))
        {
            switch (p.error())
            {
            case (QProcess::FailedToStart) :
                strError = tr("The process failed to start. Either the invoked "
                              "program is missing, or you may have insufficient permissions to invoke the program.");
                break;
            case (QProcess::Crashed) :
                strError = tr("The process crashed some time after starting successfully.");
                break;
            case (QProcess::WriteError) :
                strError = tr("An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.");
                break;
            case (QProcess::ReadError):
                strError = tr("An error occurred when attempting to read from the process. For example, the process may not be running.");
                break;
            default:
                strError = tr("An unknown error occurred.");
            }
    
            QMessageBox msgBox;
            msgBox.setWindowTitle(tr("!!!"));
            msgBox.setIcon(QMessageBox::Warning);
            msgBox.setText(strError);
            msgBox.setStandardButtons(QMessageBox::Ok);
            msgBox.exec();
        }
    

    I Wrote this code, but this code not working properly for me.
    I want to recover from a dumped SQLite database. this code
    This code just restores the normal txt file at 0 bytes only, and also shows the dumped file as 0 bytes in size.
    I don't know what is going wrong.
    Any answers you know are welcome.

    Thank

    JonBJ 1 Reply Last reply
    0
    • Ramkumar MohanR Ramkumar Mohan

      Hi,

          QString strError;
          QString strPathSqlite;
          QString fileName = "Dump.sql";
          QProcess p;
          p.setStandardOutputFile(fileName);
          p.setWorkingDirectory("/home/pi/git/");
          strPathSqlite = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/sqlite3");
          strPathSqlite.replace("\\","\\\\");
          p.start(strPathSqlite + " /home/pi/bc.db < " + fileName);
          qDebug()<<strPathSqlite;
          qDebug()<<fileName;
          if (!p.waitForStarted() || !p.waitForFinished(-1) || (p.exitStatus() != QProcess::NormalExit))
          {
              switch (p.error())
              {
              case (QProcess::FailedToStart) :
                  strError = tr("The process failed to start. Either the invoked "
                                "program is missing, or you may have insufficient permissions to invoke the program.");
                  break;
              case (QProcess::Crashed) :
                  strError = tr("The process crashed some time after starting successfully.");
                  break;
              case (QProcess::WriteError) :
                  strError = tr("An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.");
                  break;
              case (QProcess::ReadError):
                  strError = tr("An error occurred when attempting to read from the process. For example, the process may not be running.");
                  break;
              default:
                  strError = tr("An unknown error occurred.");
              }
      
              QMessageBox msgBox;
              msgBox.setWindowTitle(tr("!!!"));
              msgBox.setIcon(QMessageBox::Warning);
              msgBox.setText(strError);
              msgBox.setStandardButtons(QMessageBox::Ok);
              msgBox.exec();
          }
      

      I Wrote this code, but this code not working properly for me.
      I want to recover from a dumped SQLite database. this code
      This code just restores the normal txt file at 0 bytes only, and also shows the dumped file as 0 bytes in size.
      I don't know what is going wrong.
      Any answers you know are welcome.

      Thank

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Ramkumar-Mohan said in How to restore a backed up sqlite database ?:

      strPathSqlite.replace("\\","\\\\");

      You are under Linux, right? (Would really help if you said so, I have to guess this from "/home/pi/git/"....) What in the world is this for?

      p.start(strPathSqlite + " /home/pi/bc.db < " + fileName);

      Your command line contains a redirection symbol. You must run it through a shell to have that interpreted.

      Ramkumar MohanR 1 Reply Last reply
      0
      • JonBJ JonB

        @Ramkumar-Mohan said in How to restore a backed up sqlite database ?:

        strPathSqlite.replace("\\","\\\\");

        You are under Linux, right? (Would really help if you said so, I have to guess this from "/home/pi/git/"....) What in the world is this for?

        p.start(strPathSqlite + " /home/pi/bc.db < " + fileName);

        Your command line contains a redirection symbol. You must run it through a shell to have that interpreted.

        Ramkumar MohanR Offline
        Ramkumar MohanR Offline
        Ramkumar Mohan
        wrote on last edited by
        #3

        @JonB

        Your command line contains a redirection symbol. You must run it through a shell to have that interpreted.

        It's working fine now,

        Thank you.

        JonBJ 1 Reply Last reply
        0
        • Ramkumar MohanR Ramkumar Mohan

          @JonB

          Your command line contains a redirection symbol. You must run it through a shell to have that interpreted.

          It's working fine now,

          Thank you.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Ramkumar-Mohan said in How to restore a backed up sqlite database ?:

          It's working fine now,

          And how did you achieve that?

          Ramkumar MohanR 1 Reply Last reply
          0
          • JonBJ JonB

            @Ramkumar-Mohan said in How to restore a backed up sqlite database ?:

            It's working fine now,

            And how did you achieve that?

            Ramkumar MohanR Offline
            Ramkumar MohanR Offline
            Ramkumar Mohan
            wrote on last edited by
            #5

            @JonB

            I just ran the shell command via qprocess.

            QProcess p;
            p.setWorkingDirectory("/home/pi/git/Biochemistry-Updates/BCUID/");
            p.start("sh",QStringList()<<"-c"<<"sudo sqlite3 /home/pi/git/bc.db < /home/pi/Dump.sql");
            if (!p.waitForStarted())
            {
            qDebug()<<"ERROR";
            }
            qDebug()<<"No ERROR";
            p.waitForFinished(-1);

            JonBJ 1 Reply Last reply
            0
            • Ramkumar MohanR Ramkumar Mohan

              @JonB

              I just ran the shell command via qprocess.

              QProcess p;
              p.setWorkingDirectory("/home/pi/git/Biochemistry-Updates/BCUID/");
              p.start("sh",QStringList()<<"-c"<<"sudo sqlite3 /home/pi/git/bc.db < /home/pi/Dump.sql");
              if (!p.waitForStarted())
              {
              qDebug()<<"ERROR";
              }
              qDebug()<<"No ERROR";
              p.waitForFinished(-1);

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Ramkumar-Mohan said in How to restore a backed up sqlite database ?:

              p.start("sh",QStringList()<<"-c"<<"sudo sqlite3 /home/pi/git/bc.db < /home/pi/Dump.sql");

              Perfect, well done!

              Amongst other cases, you must do this if you command line contains the >, >>, <, |, & and a few other shell symbols.

              Ramkumar MohanR 1 Reply Last reply
              0
              • JonBJ JonB

                @Ramkumar-Mohan said in How to restore a backed up sqlite database ?:

                p.start("sh",QStringList()<<"-c"<<"sudo sqlite3 /home/pi/git/bc.db < /home/pi/Dump.sql");

                Perfect, well done!

                Amongst other cases, you must do this if you command line contains the >, >>, <, |, & and a few other shell symbols.

                Ramkumar MohanR Offline
                Ramkumar MohanR Offline
                Ramkumar Mohan
                wrote on last edited by
                #7

                @JonB

                Amongst other cases, you must do this if you command line contains the >, >>, <, |, & and a few other shell symbols.

                Ok, Thank you.

                1 Reply Last reply
                0
                • sysinfotoolsS Offline
                  sysinfotoolsS Offline
                  sysinfotools
                  wrote on last edited by
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0

                  • Login

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