#!/usr/bin/env perl use Mojolicious::Lite; use Mojo::mysql; helper mysql => sub { state $pg = Mojo::mysql->new('mysql://mysql://sri:s3cret@localhost/db') }; get '/index' => sub { my $c = shift; my $db = $c->mysql->db; $db->query('select now() as time')->hash; }; app->start; __DATA__ @@ index.html.ep