in reply to Re^4: Invert a hash... not a FAQ (I hope)
in thread Invert a hash... not a FAQ (I hope)
As you see, the DBI API is not that complex. Basic selects are not that hard. Inserts aren't that bad either. The real trickiness will be figuring out the date-time handling in your database, but you can just look at an appropriate manual until you get familiar with them. Oh right, and you have to create the table and indexes. But you only have to figure that out once.use DBI; my $dbh = DBI->connect( "dbi:Pg:host=$host;database=$database", $user, $password, { AutoCommit => 0, RaiseError => 1, }, ) or die "Can't connect: $DBI::errstr"; my $data = $dbh->selectall_arrayref(qq{ SELECT MAX(price) as max_price FROM data_log WHERE price_date > now()::date - 5 AND to_char(price_date, 'HH24') = '06' }) or die "Cannot prepare: $DBI::errstr"; print $data->[0][0];
|
|---|