/[cvs.andrew.net.au]/stock/update_market.pl
ViewVC logotype

Annotation of /stock/update_market.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Thu Mar 14 13:23:57 2002 UTC (20 years, 8 months ago) by apollock
Branch point for: MAIN, stock
File MIME type: text/plain
Initial revision

1 apollock 1.1 #!/usr/bin/perl
2    
3     use Pg;
4    
5     $start = 0;
6     $db = "stock";
7     $db_user = "postgres";
8     $db_password = "ybgz004";
9    
10     $conn = Pg::connectdb("dbname=$db user=$db_user password=$db_password");
11    
12     while(<>) {
13     if ($start) {
14     chop;
15     ($code, $date, $open, $high, $low, $close, $volume) = split(",");
16     $date =~ /(..)(..)(..)/;
17     $date = "20${1}-${2}-${3}";
18     #print "$code,$date,$open,$high,$low,$close,$volume\n";
19     #print;
20     $query = "INSERT INTO market VALUES ('$code', '$date', $open, $high, $low, $close, $volume)";
21     #print "$query\n";
22     $result = $conn->exec($query);
23     }
24     if (/^-- CUT/) {
25     # sit up and take notice
26     $start = 1;
27     }
28     }

  ViewVC Help
Powered by ViewVC 1.1.22