App-Chart

 view release on metacpan or  search on metacpan

lib/App/Chart/Database.pm  view on Meta::CPAN

      return $ret;
    } else {
      my $err = $@;
      $dbh->rollback;
      die $err;
    }

  } else {
    $subr->();
  }
}

sub preference_get {
  my ($class, $key, $default) = @_;
  my $value = read_notes_single
    ('SELECT value FROM preference WHERE key=?', $key);
  if (defined $value) {
    return $value;
  } else {
    return $default;
  }
}


1;
__END__

=for stopwords delisted

=head1 NAME

App::Chart::Database -- database functions

=head1 FUNCTIONS

=over 4

=item C<< App::Chart::Database->add_symbol ($symbol) >>

Add C<$symbol> to the database.  If C<$symbol> is already in the database
then remove its "historical" marker.

=item C<< App::Chart::Database->delete_symbol ($symbol, $notes_too) >>

Delete all data relating to C<$symbol> from the database.  If C<$notes_too>
is given and it's true then delete user notes and annotations too.

=back

=head2 Symbol Info

=over 4

=item C<< App::Chart::Database->symbol_exists ($symbol) >>

Return true if C<$symbol> exists in the database.

=item App::Chart::Database->symbol_is_historical ($symbol)

Return true if C<$symbol> is marked as historical, meaning it's delisted, or
renamed, or whatever, but in any case is no longer actively trading.

=item C<< App::Chart::Database->symbol_name ($symbol) >>

Return the stock or commodity name for C<$symbol>, obtained from the
database.

=item C<< App::Chart::Database->symbol_decimals ($symbol) >>

Return the number of decimal places normally shown on prices for C<$symbol>.
For example prices in dollars might have this as 2 to show dollars and
cents.

It's possible particular prices in the database or a quote might have more
than this many places.  The return is 0 if there's no information on
C<$symbol>.

=back

=head2 Other

=over 4

=item C<< $value = App::Chart::Database->read_extra ($symbol, $key) >>

=item C<< App::Chart::Database->write_extra ($symbol, $key, $value) >>

Read or write extra data associated with C<$symbol>.  C<$key> is a string
describing the data, C<$value> is a string or C<undef>.  C<undef> means
delete the data.

C<$symbol> can be the empty string "" for global extra data.  Some data
sources cache information this way.

=back

=head1 SEE ALSO

L<App::Chart>

=head1 HOME PAGE

L<http://user42.tuxfamily.org/chart/index.html>

=head1 LICENCE

Copyright 2008, 2009, 2010, 2011 Kevin Ryde

Chart is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.

Chart is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
details.

You should have received a copy of the GNU General Public License along with
Chart; see the file F<COPYING>.  Failing that, see
L<http://www.gnu.org/licenses/>.



( run in 1.700 second using v1.01-cache-2.11-cpan-39bf76dae61 )