Perl and MySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Buff Miner
    New Member
    • Jul 2007
    • 4

    Perl and MySQL

    I'm trying to parse an input file and then take data from that file and enter it into a MySQL database. I'm separating the fields with tabs '\t' and ending the records with a newline '\n'. I'm using the LOAD DATA function (see the code snippet below).

    # Load the data into the history table
    my $sql_statmnt2 = "LOAD DATA LOCAL INFILE \'$history_file \'
    INTO TABLE History";
    print "$sql_statm nt2 \n";
    $sth2 = $dbh->prepare($sql_s tatmnt2);
    $sth2->execute();
    $sth2->finish();

    However, I only get the first record not all of them. I've looked at the file with an editor that shows invisible characters and the tabs and newlines show up.

    Thanks!

    Buff
  • Buff Miner
    New Member
    • Jul 2007
    • 4

    #2
    I figured out why it was not working.

    Please close this thread.

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      Originally posted by Buff Miner
      I figured out why it was not working.
      Ok, care to share?

      Originally posted by Buff Miner
      Please close this thread.
      Just don't post anything to it. :)

      Regards,

      Jeff

      Comment

      • miller
        Recognized Expert Top Contributor
        • Oct 2006
        • 1086

        #4
        Originally posted by Buff Miner
        I figured out why it was not working.
        Thanks for letting us know.

        I also would be curious to know what your solution to the problem was. Was it simply a usage error, or is there some trick that is needed to get the data of your format to work?

        - Miller

        Comment

        Working...