ericlee has asked for the wisdom of the Perl Monks concerning the following question:
I've used Perl on and off for some 9 years now, but have not had the chance to use it together with MySQL until now. I have a script which reads through a flat ASCII database and adds records using INSERT to a MySQL database. The problem is, it misses some of the records (maybe 20% of them). The same records are skipped each time I try to do this. And the records being skipped are not duplicates; they have a unique key which isn't in the MySQL database.
Here are the relevant lines of code in my Perl script:
$db->do("INSERT INTO news (url, header, country, country2, date, priority, userid, source, formoreinfo, language, regreqd, keywords, image, actnowcampaigncode, state) VALUES ('$url', '$header', '$country1', '$country2', $date, $priority, '$correspondent', '$source', '$formoreinfo', '$language', '$regreqd', '$keywords', '$image', '$actnowcampaigncode', '$state')");The unique key in table 'news' is the first field, url.
I cannot figure out why certain records are being skipped. And looking over and over at the records being skipped, I cannot see how they differ from other records which are being added.
For example, here are three records in the flat ASCII database -- the middle one is skipped, the other two are successfully added:
http://montreal.cbc.ca/regional/servlet/View?filename=qc_hema20030513| +Quebec blood workers threaten to strike|Canada||15-May-2003|2|dblacka +dder|CBC||English|No||| http://www.izf.net/izf/AFP/francais/topics/togo/030513165556.mvvte7lp. +html|Libération d'un journaliste après quatre mois de détention|Togo| +|15-May-2003|2|jacquot|izf||French|No||| http://pei.cbc.ca/regional/servlet/View?filename=pe_uniontalks20030414 +|PEI union and Polar Foods end contract talks|Canada||15-May-2003|2|d +blackadder|CBC||English|No|||
Any ideas? Thanks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl DBI adding some, not all, records to MySQL database
by jettero (Monsignor) on Jul 06, 2007 at 10:39 UTC | |
Re: Perl DBI adding some, not all, records to MySQL database
by jeanluca (Deacon) on Jul 06, 2007 at 10:29 UTC | |
Re: Perl DBI adding some, not all, records to MySQL database
by naikonta (Curate) on Jul 06, 2007 at 10:45 UTC | |
Re: Perl DBI adding some, not all, records to MySQL database
by Moron (Curate) on Jul 06, 2007 at 10:51 UTC | |
Re: Perl DBI adding some, not all, records to MySQL database
by snopal (Pilgrim) on Jul 06, 2007 at 13:58 UTC | |
Re: Perl DBI adding some, not all, records to MySQL database
by webfiend (Vicar) on Jul 06, 2007 at 19:20 UTC | |
by ericlee (Novice) on Jul 09, 2007 at 10:42 UTC |