Skip to content

Instantly share code, notes, and snippets.

@bigpresh
Created March 26, 2010 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigpresh/344333 to your computer and use it in GitHub Desktop.
Save bigpresh/344333 to your computer and use it in GitHub Desktop.
port: 4002
dsn: "dbi:SQLite:dbname=test.db"
#!/usr/bin/perl
use Dancer;
use DBI;
{
my $database;
sub database { return $database ||= DBI::connect(setting('dsn')); }
}
get '/' => sub {
my $sth = database()-prepare('select * from mytable');
$sth->execute;
while (my $row = $sth->fetchrow_hashref) {
print "<p>$row->{foo}</p>";
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment