Helo,
I found at forum somebodys post:
I'm trying to parse an input file and then take data from that file and enter it into a MySQL database. I'm separating the fields with tabs '\t' and ending the records with a newline '\n'. I'm using the LOAD DATA function (see the code snippet below).
[CODE=perl]# Load the data into the history table
my $sql_statmnt2 = "LOAD DATA LOCAL INFILE \'$history_file \'
INTO TABLE History";
print "$sql_statm nt2 \n";
$sth2 = $dbh->prepare($sql_s tatmnt2);
$sth2->execute();
$sth2->finish();[/CODE]
However, I only get the first record not all of them. I've looked at the file with an editor that shows invisible characters and the tabs and newlines show up.
Thanks!
I have the same problem...
my file is temp1.txt , doses it mean I put it in a script as a variable?just like above? does any one know how to solve it?
when I try this script it doesn't work at all
what am I doing wrong please help!I would be grateful very very much...
my script is...(basing on the above):
[CODE=perl]#!/usr/bin/perl -w
use CGI qw(:standard);
use CGI::Carp qw(warningsToBr owser fatalsToBrowser );
use DBI;
# BD connection----------------------------------------
my $dbh = DBI->connect('dbi:m ysql:monitoring ','root','passw d')
or die "Connection Error: $DBI::errstr\n" ;
my $sql_statmnt2 = "LOAD DATA LOCAL INFILE \'$temp1.txt\'
INTO TABLE room1_temperatu re";
print "$sql_statm nt2 \n";
$sth2 = $dbh->prepare($sql_s tatmnt2);
$sth2->execute();
$sth2->finish();[/CODE]
----------------------------------------------
\'$temp1.txt\' or \'$temp1\' without a file type?
I found at forum somebodys post:
I'm trying to parse an input file and then take data from that file and enter it into a MySQL database. I'm separating the fields with tabs '\t' and ending the records with a newline '\n'. I'm using the LOAD DATA function (see the code snippet below).
[CODE=perl]# Load the data into the history table
my $sql_statmnt2 = "LOAD DATA LOCAL INFILE \'$history_file \'
INTO TABLE History";
print "$sql_statm nt2 \n";
$sth2 = $dbh->prepare($sql_s tatmnt2);
$sth2->execute();
$sth2->finish();[/CODE]
However, I only get the first record not all of them. I've looked at the file with an editor that shows invisible characters and the tabs and newlines show up.
Thanks!
I have the same problem...
my file is temp1.txt , doses it mean I put it in a script as a variable?just like above? does any one know how to solve it?
when I try this script it doesn't work at all
what am I doing wrong please help!I would be grateful very very much...
my script is...(basing on the above):
[CODE=perl]#!/usr/bin/perl -w
use CGI qw(:standard);
use CGI::Carp qw(warningsToBr owser fatalsToBrowser );
use DBI;
# BD connection----------------------------------------
my $dbh = DBI->connect('dbi:m ysql:monitoring ','root','passw d')
or die "Connection Error: $DBI::errstr\n" ;
my $sql_statmnt2 = "LOAD DATA LOCAL INFILE \'$temp1.txt\'
INTO TABLE room1_temperatu re";
print "$sql_statm nt2 \n";
$sth2 = $dbh->prepare($sql_s tatmnt2);
$sth2->execute();
$sth2->finish();[/CODE]
----------------------------------------------
\'$temp1.txt\' or \'$temp1\' without a file type?
Comment