Listing 1. database-connect.comp

%# -*- mmm-classes: mason -*-
<%perl>
# Connect to the database
  my $host = 'localhost';
my $user = 'atfnews';
my $password = 'atfpass';
my $database = 'atfnews';
my $dsn = "DBI:mysql:database=$database;host=$host;port=3306";
$dbh = DBI->connect($dsn, $user, $password) ||
     die "Cannot connect: $DBI::errstr";
# Now return the database handle
return $dbh;
</%perl>
<%once>
my $dbh;
</%once>