List:General Discussion« Previous MessageNext Message »
From:Charles Kirby Date:April 28 1999 9:43pm
Subject:Perl DBI, for archiving
View as plain text  
Hi, I've spent a lot of time looking thru' the documentation, perldoc DBI,
and other examples, and can't get any solid examples where information is
sucked out of a mysql database without it being too cryptic.
This part of my code doesn't seem to compute well... the "$sid" doesn't go
down well, and yet this is straight from the documentation (where the
variable is "$baz").  Am I headed in the right direction at least?
What I'm trying to do is get stuff from one database on the basis of it
being over a certain age, and then insert it into an archive (parallel)
database.
Thanks!

my $dbh = DBI->connect("DBI:mysql:$dbname", $dbuser, $dbpasswd)
    or die "can't connect: $DBI::errstr\n";

my $query = <<"EOS";
SELECT sid
FROM slips
WHERE sid='1' 
EOS
my $sth = $dbh->prepare($query) or die "can't prepare $query: ",
$dbh->errstr, "
\n";  
$sth->execute($sid); 
while(@row = $sth->fetchrow_array) {
     print "@row\n";      
     }


Thread
Perl DBI, for archivingCharles Kirby29 Apr
  • Re: Perl DBI, for archivingVivek Khera29 Apr
    • Re: Perl DBI, for archivingCharles Kirby29 Apr
      • Re: Perl DBI, for archivingPaul DuBois29 Apr
      • Re: Perl DBI, for archivingVivek Khera29 Apr
        • Re: Perl DBI, for archivingCharles Kirby29 Apr
          • Re: Perl DBI, for archivingPaul DuBois29 Apr
            • Re: Perl DBI, for archivingCharles Kirby29 Apr