Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Updating or Inserting a database from a txt file

by Animator (Hermit)
on May 10, 2005 at 13:50 UTC ( #455572=note: print w/replies, xml ) Need Help??


in reply to Updating or Inserting a database from a txt file

Usless post: read at your own risk.

I should have know this node would get up-voted and front-paged...

Noone cares that this is the third time that the OP asks the same question, right?

Even when in the previous nodes working code (and good code) was suggested, clearly the OP decides not to use it and use yet another approach... Why is the biggest question I guess...

  • Comment on Re: Updating or Inserting a database from a txt file

Replies are listed 'Best First'.
Re^2: Updating or Inserting a database from a txt file
by DaWolf (Curate) on May 10, 2005 at 15:11 UTC
    Actually the OP's previous posts seem different from this one. Previously he was looking for answers and now he's looking for improvements.

    Have I missed something?

    Nik, please be polite. Rudeness will only make things worse.

    Hope you find your answers.

    Regards,
      Sorry man, i got carried away there but i become mad with the both of them and especially Animator on irc.
      Yes iam trying to improve the script as you correctly noticed.

      I changed it again. Here it is now:
      my (@row, $gamename, $gamedesc, $gamecount); my $select = $dbh->prepare( "SELECT * FROM games WHERE gamename=$gamen +ame" ); my $insert = $dbh->prepare( "INSERT INTO games (gamename, gamedesc, ga +mecounter) VALUES (?, ?, ?)" ); my $update = $dbh->prepare( "UPDATE games SET gamedesc=?, gamecount=?+ +1 where gamename=?" ); open (FILE, "<../data/games/descriptions.txt") or die $!; while (<FILE>) { chomp; ($gamename, $gamedesc) = split /\t/; $select->execute( $gamename ); if ($select->rows) { $update->execute( $gamedesc, $gamecount, $gamename ); } else { $insert->execute( $gamename, $gamedesc, 0 ); } } close (FILE);
      the descriptions.txt contains a blank line after each line of info. I dont want it to be loaded and also every time games.pl is runnign it gets doubled and doubles each time!

      Anyone can see why?
Re^2: Updating or Inserting a database from a txt file
by mlh2003 (Scribe) on May 10, 2005 at 14:00 UTC
    I didn't see the previous post :(
    Otherwise I probably would have said something similar...
    _______
    Code is untested unless explicitly stated
    mlh2003
A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://455572]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2021-10-24 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?