Howell, Scott wrote:

Has anyone written a perl script to get records from another database and
write it to a file on mysql's LOAD DATA INFILE format? I just need some
pointers in perl so a LOAD DATA INFILE will be read correctly.

For example, a perl script:
Select * from emp from a Progress database
Will write to a text file called emp.txt in the LOAD DATA INFILE format,
Then,
I can to a direct LOAD DATA INFILE into my mysql database.

I tried doing direct select/inserts in perl but found dumping to a text file
and doing a LOAD DATA to be MUCH faster.

Am I missing something here?


Download data from mysql to pipe delimited text file; whole table. SELECT * FROM table1 INTO OUTFILE 'c:/test.txt' FIELDS TERMINATED BY "|";

Same download with perl/cgi
my $statement = 'SELECT * FROM table1 INTO OUTFILE \'C:/test.txt\' FIELDS TERMINATED BY "|"';
$dbh->do($statement) or die "tilt\n";



Upload data from pipe delimited text file. Loads whole table.
LOAD DATA LOCAL INFILE "[path with front slashes] filename.txt" INTO TABLE tablename
FIELDS TERMINATED BY "|";


Note that some service providers don't like this and won't permit it.
--
Joel Fentin    tel: 760-749-8863    FAX: 760-749-8864
email:         [EMAIL PROTECTED]
Biz:           http://fentin.com
Personal:      http://fentin.com/me/


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to