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:
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=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 ();
is there a way I can make it faster because to do all the tables it take up to one hour to finish.
Thank
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.