welcome,
I input data form file to mysql with command: load data local infile..
The efect is that the data are duplicated or trippled..etc with every re-loading the script, but I need to load there only new values from file.
here is the code:
[code=perl]
#!/usr/bin/perl -w
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use DBI;
$foo = new CGI;
my @row;
print $foo->header;
$temp1 = 'temp1.txt';
# BD connection----------------------------------------
my $dbh = DBI->connect('dbi:mysql:monitoring','root','passwd')
or die "Connection Error: $DBI::errstr\n";
my $sql = "select * from room1_temperature";
my $sth = $dbh->prepare($sql);
$sth->execute;
or die "SQL Error: $DBI::errstr\n";
$sql_statmnt2 = "LOAD DATA LOCAL INFILE \'$temp1\'
INTO TABLE room1_temperature (temperature)";
print "$sql_statmnt2 \n";
$sth2 = $dbh->prepare($sql_statmnt2);
$sth2->execute();
$sth2->finish();
[code]
What should I do to avoid rewriting the same information from file to mysql.
My file is constantly updated with a new values so former loaded data to mysql can't be loaded second time..
Please help me,I would be very grateeful..
any ideas?