MySQL Forums
Forum List  »  Perl

How can I do this faster : Convert DBF to Mysql
Posted by: Armando Gomez
Date: March 11, 2008 05:46PM

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:


unlink ('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=localhost",
"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 ();



is there a way I can make it faster because to do all the tables it take up to one hour to finish.



Thanks

Options: ReplyQuote


Subject
Written By
Posted
How can I do this faster : Convert DBF to Mysql
March 11, 2008 05:46PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.