I need to move some rows of a table to other server. The tables has one operator field and what I want to do is to dump the rows that has operator field value as the currently login user.
Is there a code to call the mysqldump and write the result to a file? I like sql command as the result compare to csv since csv will be easier to be edited.
Thank you in advance.
There are many ways to acomplish it:
Call mysqldump through system(). It can even take a condition as an argument to limit the data range from a table.
Use ‘SELECT … INTO OUTFILE’ syntax in MySQL to save results of a query in a file that can be later read using ‘LOAD DATA INFILE’. This is the fastest way in MySQL to move huge amount of data.
Use some exporter widget to save data as a CSV. I made my own.
Generate a CSV or a text file holding INSERT statements yourself by iterating through results of a query and concatenating values into output text.
Have two database connections in your app and when iterating through a results set from the first connection perform insert commands on the second one.