1
2
3
4
5
6
7
8
9
10
push(@insert_historyeinstellkosten,"$row_csv[8];$row_csv[1]\n");
...
open(INPUT,'>'.$newdata);
foreach(@insert_historyeinstellkosten)
{
print INPUT $_;
}
close INPUT;
1
2
3
4
5
6
7
$table_header = "`AfterbuyNr`,`eBayNr`";
print "| Load Data für ".$mysql_pre." startet\n";
$sql = "LOAD DATA LOCAL INFILE '".$newdata."' INTO TABLE ".$mysql_table." FIELDS TERMINATED BY ';' ENCLOSED BY '\"' LINES TERMINATED BY '\n' (".$table_header.");";
$sth = $dbh->prepare( $sql );
$sth->execute();
print "| Load Data für ".$mysql_pre." beendet\n";
1
2
3
4
$sql = "update np24_ebay_afterbuy_historyeinstellkosten set eBayNr = eBayNr+'' ";
$sth = $dbh->prepare( $sql );
$sth->execute();
push(@insert_historyeinstellkosten,"\"$row_csv[8]\";\"$row_csv[1]\"\n");
$sql = "LOAD DATA LOCAL INFILE '".$newdata."' INTO TABLE ".$mysql_table." FIELDS TERMINATED BY ';' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' (".$table_header.");";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#!/usr/bin/perl use strict; use warnings; use DBI; my $table_header = q(`AfterbuyNr`,`eBayNr`); my $mysql_pre = 'test'; my $mysql_table = 'test'; my $newdata = 'test.data'; print qq(| Load Data für $mysql_pre startet\n); my $dbh = DBI->connect("dbi:mysql:test", 'test', 'test'); my ($sth, $sql); $sql = <<'SQL'; CREATE TABLE IF NOT EXISTS `test` ( `id` int(11) DEFAULT 0, `AfterbuyNr` int(11) DEFAULT 0, `eBayNr` int(11) DEFAULT 0 ); SQL $sth = $dbh->prepare( $sql ); $sth->execute(); $sql = <<SQL; LOAD DATA LOCAL INFILE '$newdata' INTO TABLE $mysql_table FIELDS TERMINATED BY ';' ENCLOSED BY '\"' LINES TERMINATED BY '\n' ($table_header); SQL $sth = $dbh->prepare( $sql ); $sth->execute(); print qq(| Load Data für $mysql_pre beendet\n);