I am using mysql4.01(with InnoDB)
I have a large application producing a few files every 10 minutes or so. These files(say file.sql) are of the form
set autocommit=0;
INSERT INTO TABLE1(field1,field2,..,fieldn) VALUES (val1,val2,...,valn);
.....
commit;
Obviously I can have a perl script parse this file line by line and do the insert via DBI.
However, I am trying to do this another way, because this is a large file, but mostly because it looks cleaner:
I am trying to do it via
system("mysql -u user -ppassword DATABASE <file.sql"
However, I also want the following:
If the bulk inert succeeds, I want to write to a file DONES
that file.sql was correctly imported and to delete that file
If this fails, I want to write to a file ERRORS that
file.sql failed to import . However something like
system("mysql -u user -ppassword DATABASE <file.sql >OUT"
open(OUTF,"OUT" or die "cannot open OUT\n";
my @msg=<OUTF>;
if(@msg){... write to ERRORS}
else{write to DONES}
does not work because I do not get in OUT the ERROR statement and instead getthe welcome to mysql.... stuff
Any ideas how to do this?
Thanks, svar
I have a large application producing a few files every 10 minutes or so. These files(say file.sql) are of the form
set autocommit=0;
INSERT INTO TABLE1(field1,field2,..,fieldn) VALUES (val1,val2,...,valn);
.....
commit;
Obviously I can have a perl script parse this file line by line and do the insert via DBI.
However, I am trying to do this another way, because this is a large file, but mostly because it looks cleaner:
I am trying to do it via
system("mysql -u user -ppassword DATABASE <file.sql"
However, I also want the following:
If the bulk inert succeeds, I want to write to a file DONES
that file.sql was correctly imported and to delete that file
If this fails, I want to write to a file ERRORS that
file.sql failed to import . However something like
system("mysql -u user -ppassword DATABASE <file.sql >OUT"
open(OUTF,"OUT" or die "cannot open OUT\n";
my @msg=<OUTF>;
if(@msg){... write to ERRORS}
else{write to DONES}
does not work because I do not get in OUT the ERROR statement and instead getthe welcome to mysql.... stuff
Any ideas how to do this?
Thanks, svar