Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 138736e54c
Fetching contributors…

Cannot retrieve contributors at this time

28 lines (23 sloc) 0.544 kB
#!/usr/local/bin/perl6
use FakeDBI;
use JSON::Tiny;
use CGI:from<perl5>;
# Print a header.
my $cgi = CGI.new(%*ENV<QUERY_STRING>);
print $cgi.header('text/plain');
# Connect to the DB.
my $dbh = FakeDBI.connect(
'FakeDBI:mysql:database=my_db;host=localhost',
'user', 'pass');
# Load the data.
my $sth = $dbh.prepare('
SELECT name, info, map_latitude, map_longitude
FROM beers');
$sth.execute();
my @beers;
while my $beer = $sth.fetchrow_hashref() {
push @beers, $beer;
}
$sth.finish();
# Emit JSON.
say to-json(@beers);
Jump to Line
Something went wrong with that request. Please try again.