padawan_linuxero has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks!
I have a question for all of you, here in my work place, I need to take out a lot of data from several (like 7) tables from a FoxPro app in DOS, and put it in MySQL tables so I have done a little script to take out the data, the script work it does what is suppose to do, but it take a lot of time doing this operation. How can I make it faster??? this is the code:
I have a question for all of you, here in my work place, I need to take out a lot of data from several (like 7) tables from a FoxPro app in DOS, and put it in MySQL tables so I have done a little script to take out the data, the script work it does what is suppose to do, but it take a lot of time doing this operation. How can I make it faster??? this is the code:
is there a way I can make it faster because to do all the tables it take up to one hour to finish. Thankunlink ('c:/proyecto/r501.csv'); #---- This part conects to my 2 databases one CSV and one MySql ----- my $dbhX1 = DBI->connect('dbi:XBase(RaiseError=1):'); my $dbhC1 = DBI->connect('dbi:CSV(RaiseError=1):'); my $select1 = $dbhX1->prepare("SELECT * FROM r501"); print "\nEjecutar SELECT de r501\n"; $select1->execute(); $dbhC1->do("CREATE TABLE r501.csv AS IMPORT(?)",{},$select1); print "\nconectar al a base de datos en Mysql\n"; my $mysql_dbh1 = DBI->connect("DBI:mysql:database=$datafilename;host=l +ocalhost", "root", "xyz123", {'RaiseError' => 1}); #---- Here I empty the table in MySql ------ print "Limpiando la tabla\n"; $mysql_dbh1->do("TRUNCATE TABLE r501"); #---- Here I load all the data ------- my $sql1 = "LOAD DATA LOCAL INFILE 'c:/proyecto/r501.csv' INTO TABLE r501 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'"; my $sth1 = $mysql_dbh1->prepare($sql1); print "ejecutando la carga de la tabla\n"; $sth1->execute ();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: how can I make this faster
by igelkott (Priest) on Mar 10, 2008 at 20:51 UTC | |
by Errto (Vicar) on Mar 10, 2008 at 22:42 UTC | |
Re: how can I make this faster
by CountZero (Bishop) on Mar 10, 2008 at 22:37 UTC |
Back to
Seekers of Perl Wisdom