awohld has asked for the wisdom of the Perl Monks concerning the following question:
my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;") or die "Cannot connect: " . $DBI::errstr; $dbh->{'csv_tables'}->{'bt'} = { 'file' => './X_Con.csv'}; $dbh->{'csv_tables'}->{'sec'} = { 'file' => './Y_Con.csv'}; $dbh->{'csv_tables'}->{'stats'} = { 'file' => './Z_Con.csv'}; my $sth_sec = $dbh->prepare("SELECT KEY, TEST, INSTANCE, ID, HID FROM +sec") or die "Can't prepare SQL statement: $DBI::errstr\n"; my $sth_bt = $dbh->prepare("SELECT NAME, STATE FROM bt WHERE ID =? AND + HID=?") or die "Can't prepare SQL statement: $DBI::errstr\n"; my $sth_stats = $dbh->prepare("SELECT CCS, kbps, MBytes FROM stats WHE +RE ID=? AND HID=? & INSTANCE=?") or die "Can't prepare SQL statement: $DBI::errstr\n"; $sth_sec->execute() or die "Can't execute SQL statement: $DBI::errstr\n"; open(TRAFFICSTATS,'>',"NoThroughput.csv") || die("Cannot Open File"); { my $old_sel = select(TRAFFICSTATS); $| = 1; # Auto-flush. select($old_sel); } print TRAFFICSTATS "KEY,ID,HID,NAME,STATE,CCS,kbps,MBytes\n"; while ( my @row = $sth_sec->fetchrow_array ) { my ( $keyId, $testCarrier, $instanceId, $id, $hId ) = @row; $sth_bt->execute( $id, $hId ); @row = $sth_bt->fetchrow_array; my ( $name, $state ) = @row; $sth_stats->execute($id, $hId, $instanceId ); @row = $sth_stats->fetchrow_array; my ( $CCS, $kbps, $mBytes ) = @row; print TRAFFICSTATS "$keyId,$id,$hId,$name,$state,$CCS,$kbps,$mBytes +\n"; } close TRAFFICSTATS;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to make my DBD::CSV DB code faster.
by CountZero (Bishop) on Sep 29, 2005 at 21:51 UTC | |
|
Re: How to make my DBD::CSV DB code faster.
by graff (Chancellor) on Sep 29, 2005 at 22:29 UTC | |
by jZed (Prior) on Sep 30, 2005 at 02:47 UTC | |
|
Re: How to make my DBD::CSV DB code faster.
by jZed (Prior) on Sep 30, 2005 at 02:36 UTC | |
|
Re: How to make my DBD::CSV DB code faster.
by davidrw (Prior) on Sep 30, 2005 at 02:21 UTC | |
by jZed (Prior) on Sep 30, 2005 at 02:39 UTC | |
|
Re: How to make my DBD::CSV DB code faster.
by dragonchild (Archbishop) on Sep 30, 2005 at 01:57 UTC | |
by jZed (Prior) on Sep 30, 2005 at 02:42 UTC |