Thread Schönheitsfrage bei Load Data mit \n (8 answers)
Opened by andi84 at 2011-10-17 16:23

GwenDragon
 2011-10-18 14:54
#153304 #153304
User since
2005-01-17
14581 Artikel
Admin1
[Homepage]
user image
Ich habe mit folgendem Testskript mit MySQL 5.1 keine Probleme Daten hinzuzufügen:
Code (perl): (dl )
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);


mit folgendem Datendatei (Zeilenende \x0A):
Code: (dl )
1
2
"100111";"123456777"
"100777";"123456999"


Da sind dann auch keien seltsamen Zeichen drin wie bei dir.
Last edited: 2011-10-18 14:55:34 +0200 (CEST)
die Drachin Gwendolyn

View full thread Schönheitsfrage bei Load Data mit \n