The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojolicious::Plugin::Database - "proper" handling of DBI based connections in Mojolicious

VERSION

Version 0.02

SYNOPSIS

Provides "sane" handling of DBI connections so problems with pre-forking (Hypnotoad, etc.) will not occur.

use Mojolicious::Plugin::Database;

sub startup {
    my $self = shift;

    $self->plugin('database', { 
        dsn      => 'dbi:Pg:dbname=foo',
        username => 'myusername',
        password => 'mypassword',
        options  => { 'pg_enable_utf8' => 1, AutoCommit => 0 },
        helper   => 'db',
        });
}

CONFIGURATION

The only required option is the 'dsn' one, which should contain a valid DBI dsn to connect to your database of choice. The actual connection is made when the plugin is registered.

METHODS/HELPERS

A helper is created with a name you specified (or 'db' by default) that can be used to get the active DBI connection.

AUTHOR

Ben van Staveren, <madcat at cpan.org>

BUGS

Please report any bugs or feature requests to bug-mojolicious-plugin-database at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mojolicious-Plugin-Database. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Mojolicious::Plugin::Database

You can also look for information at:

ACKNOWLEDGEMENTS

Based on a small example by sri and his request if someone could please write a plugin for this stuff.

LICENSE AND COPYRIGHT

Copyright 2011 Ben van Staveren.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.