473,395 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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

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

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

Similar topics

11
by: Bruce A. Julseth | last post by:
Newbie Question: Is there a way to import MS Access into MySQL? Maybe create a CSV or something. If so, what would be the SQL to do this? Thanks... Bruce
14
by: Bruce A. Julseth | last post by:
When I execute this SQL statement in my PHP code, I get an error "File '.\Address.txt' not found (Errcode: 2)" $File = addslashes(".\Address.txt"); $SQL = "Load Data InFile \"" . $File . "\"...
0
by: Madhu Nair | last post by:
I am getting errors while compiling DBD-mysql 2.9002 on HP-UX 11.00 I have perl 5.8 downloaded from HP depot installed at /opt/perl Mysql 4.0.13 compiled myself with gcc with Mysql recommended...
2
by: Vincent Bouret | last post by:
Hi, I have read that Unicode (UTF-8) was not enabled by default in the mysql-4.1.0-alpha binaries. How can I enable it? What should I change in the code to do so? Thanks Vincent
0
by: Richard F. Rebel | last post by:
--=-wjMACH/Y8yu26LgbKddl Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hello, After recently replicating using the stop databases and copy innodb and mysql files...
1
by: Ray in HK | last post by:
What are the differences between LOAD DATA INFILE and LOAD DATA LOCAL INFILE ? I found some web hosting company do not allow using LOAD DATA INFILE but allow LOAD DATA LOCAL INFILE. The reason...
3
by: Bruce A. Julseth | last post by:
I can export from Access and Load Data InFile into MySQL but was wondering if there is a direct way of loading MySQL from Access? Thank you.
0
by: phil | last post by:
I am having a problem with the C api with prepared statements, the data recorded in the database does not match the data I am sending. It seems to be some sort of bit shifted version of the data,...
10
by: Simon | last post by:
Hi, I need to export a 200MB database from one domain to another. phpMyAdmin timeout after a while and is not ideal. I don't mind spending money if I have to but this is rather urgent. I...
7
by: greywire | last post by:
So I need to load lots of data into my database. So I discover LOAD DATA INFILE. Great! This little gem loads my CSV in blazing times (compared to parsing the file and doing INSERT for each...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.