470,862 Members | 1,640 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,862 developers. It's quick & easy.

mysql perl - load data local infile...re-writes whole file when I need only updats;/


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:
#!/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);
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);

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?
Dec 4 '07 #1
1 3673
what more...the code:

Expand|Select|Wrap|Line Numbers
  1.       LOAD DATA INFILE '$temp1'
  2.       IGNORE INTO TABLE .......;
dosen't work... to ignor repeating values...
what can I do ...please help...
Dec 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Bruce A. Julseth | last post: by
14 posts views Thread by Bruce A. Julseth | last post: by
reply views Thread by Madhu Nair | last post: by
2 posts views Thread by Vincent Bouret | last post: by
reply views Thread by Richard F. Rebel | last post: by
3 posts views Thread by Bruce A. Julseth | last post: by
10 posts views Thread by Simon | last post: by
7 posts views Thread by greywire | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.