Changeset 230 for trunk/npemap.org.uk/scripts
- Timestamp:
- Oct 29, 2006, 6:10:20 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/npemap.org.uk/scripts/content/update_stats.pl
r220 r230 13 13 use lib "$FindBin::Bin/../../perllib"; 14 14 use NPEMap::Postcodes; 15 16 use vars qw($dbname $dbhost $dbuser $dbpass); 15 use NPEMap; 17 16 18 17 sub print_err; 19 18 sub setup_dbh; 20 19 21 # Read in database config22 my $config = 'npemap.conf';23 do $config or die "Can't read $config!\n";24 25 26 # No point in handling errors here since they'll get handled by the request27 # handler28 20 my $dbh; 29 21 30 31 22 # In case the database went away, make sure we have a connection 32 unless ( setup_dbh()) {23 unless ($dbh = setup_dbh()) { 33 24 print_internal_err('Error setting up database connection'); 34 25 } … … 36 27 build_home_stats($dbh); 37 28 38 39 # No more requests to serve, so tidy up40 29 $dbh->disconnect; 41 30 … … 52 41 print "Error: $err\n"; 53 42 } 54 55 sub setup_dbh {56 # $dbh is global57 my $data_source = "dbi:Pg:dbname=$dbname";58 $data_source .= ";host=$dbhost" if $dbhost;59 return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);60 }
Note: See TracChangeset
for help on using the changeset viewer.