Created
March 26, 2010 00:47
-
-
Save bigpresh/344333 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
port: 4002 | |
dsn: "dbi:SQLite:dbname=test.db" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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