in reply to Help with Finance::QuoteHist
This will allow you to grab less data at one whack. I'll also throw in some prettier constructs which use fewer temporary variables.
#!/usr/bin/perl -w use strict; use DBI; use Finance::QuoteHist; my $user="me"; my $password="pass"; my $database="stocks"; my $dbh=DBI->connect("dbi:mysql:$database",$user,$password,{RaiseError +=>1}) or die "Cannot connect to database"; my $syms = $dbh->selectcol_arrayref("Select symbol from symbols"); my $sth=$dbh->prepare("INSERT INTO stocks (symbol,date,open,high,low,close,volume,adjuste +d) VALUES(?,?,?,?,?,?,?,?)"); for (@{$syms}) { my $q = new Finance::QuoteHist( symbols => [$_], # just one symbol start_date => '01/01/2001', end_date => 'today'); for ($q->quotes()){ $sth->execute(@{$_}); } #next stock symbol now } # done $dbh->disconnect();
The selectcol_arrayref call is relatively new in DBI.pm. If it's unavailable, what you have will work just fine.
After Compline,
Zaxo
|
|---|