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. copy table contents accros different servers in Qt
Forum Updated to NodeBB v4.3 + New Features

copy table contents accros different servers in Qt

Scheduled Pinned Locked Moved General and Desktop
qsqldatabaseqt5.4
6 Posts 3 Posters 2.6k Views 2 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.
  • A Offline
    A Offline
    alizadeh91
    wrote on last edited by
    #1

    In developing a Qt application I need to copy contents of a mysql table from serverA(PC-A) to serverB(PC-B). What is best way to do this? (I can't use dumpmysql and don't want to use QProcess.exe)

    THANKS

    M 1 Reply Last reply
    0
    • A alizadeh91

      In developing a Qt application I need to copy contents of a mysql table from serverA(PC-A) to serverB(PC-B). What is best way to do this? (I can't use dumpmysql and don't want to use QProcess.exe)

      THANKS

      M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      @alizadeh91 said:

      In developing a Qt application I need to copy contents of a mysql table from serverA(PC-A) to serverB(PC-B). What is best way to do this? (I can't use dumpmysql and don't want to use QProcess.exe)

      THANKS

      Hi,
      obviously the "dumpsql" solution is the best way but if you cannot use it (I'm curious about why..) the only solution I can suggest is;

      1. Create two QSqlDatabase connections
      2. Load all data from the serverA
      3. Insert all data into the serverB

      Happy Programming

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      A 1 Reply Last reply
      0
      • A Offline
        A Offline
        alizadeh91
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • M mcosta

          @alizadeh91 said:

          In developing a Qt application I need to copy contents of a mysql table from serverA(PC-A) to serverB(PC-B). What is best way to do this? (I can't use dumpmysql and don't want to use QProcess.exe)

          THANKS

          Hi,
          obviously the "dumpsql" solution is the best way but if you cannot use it (I'm curious about why..) the only solution I can suggest is;

          1. Create two QSqlDatabase connections
          2. Load all data from the serverA
          3. Insert all data into the serverB

          Happy Programming

          A Offline
          A Offline
          alizadeh91
          wrote on last edited by
          #4

          @mcosta How can I use dumpsql within c++ programming?

          fecubF 1 Reply Last reply
          0
          • A alizadeh91

            @mcosta How can I use dumpsql within c++ programming?

            fecubF Offline
            fecubF Offline
            fecub
            wrote on last edited by fecub
            #5

            @alizadeh91

            Do a full backup of your databases:
            shell> mysqldump --tab=/path/to/some/dir --opt --full
            or
            shell> mysqlhotcopy database /path/to/some/dir

            You can also simply copy all table files (*.frm', .MYD', and `.MYI' files) as long as the server isn't updating anything.

            restore with:
            shell> mysqlbinlog hostname-bin.[0-9]* | mysql

            or an antoher alternative is:

            shell>mysqldump --opt database > backup-file.sql

            restore:
            mysql database < backup-file.sql

            or

            mysql -e "source /patch-to-backup/backup-file.sql" database

            In addition, you can still do the following:

            However, it's also very useful to populate another MySQL server with information from a database:

            mysqldump --opt database | mysql --host=remote-host -C database

            It is possible to dump several databases with one command:

            mysqldump --databases database1 [database2 database3...] > my_databases.sql

            If all the databases are wanted, one can use:

            mysqldump --all-databases > all_databases.sql

            --> solution in c++:

            C++:
            ShellExecute(0, "open", "c:\\mysql\\bin\\mysqldump.exe", "--opt database > backup-file.sql", 0, SW_SHOWNORMAL);	
            
            restore:
            C++:
            ShellExecute(0, "open", "c:\\mysql\\bin\\mysql.exe", database < backup-file.sql", 0, SW_SHOWNORMAL);
            

            hope this helps

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mcosta
              wrote on last edited by mcosta
              #6

              Instead of ShellExecute, you can also use QProcess in Qt programs

              Why you don't want use QProcess???

              Once your problem is solved don't forget to:

              • Mark the thread as SOLVED using the Topic Tool menu
              • Vote up the answer(s) that helped you to solve the issue

              You can embed images using (http://imgur.com/) or (http://postimage.org/)

              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