Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Here is the code
Thanks in advance#!/usr/bin/perl -w use strict; use DBI; use Finance::QuoteHist; my $user="me"; my $password="pass"; my $database="stocks"; my @data; my $i=0; my $dbh=DBI->connect("dbi:mysql:$database",$user,$password) or die "Ca +nnot connect to database"; $dbh->{raiserror} = 1; my $sth=$dbh->prepare("Select symbol from symbols;"); $sth->execute(); while(my @row=$sth->fetchrow_array()){ $data[$i]=$row[0]; $i++; } #Here is what I am having trouble with. my $q = new Finance::QuoteHist( symbols =>\@data, start_date => '01/01/01', end_date => 'today'); my @quotes = $q->quotes(); my $sth=$dbh->prepare("INSERT INTO stocks(symbol,date,open,high,low,cl +ose,volume,adjusted) VALUES(?,?,?,?,?,?,?,?);"); for my $i (0 .. $#quotes){ $sth->execute($quotes[$i][0],$quotes[$i][1],$quotes[$i][2],$quotes +[$i][3],$quotes[$i][4],$quotes[$i][5],$quotes[$i][6],$quotes[$i][7])| +| die "error: ", $dbh->errstr; } #if any one knows how to make this a little bit prettier I would also +appreciate it!! $dbh->disconnect();
Will
Edit: chipmunk 2001-07-16
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with Finance::QuoteHist
by Zaxo (Archbishop) on Jul 16, 2001 at 10:56 UTC |