GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MOJOLICIOUS::PLUGIN::DATABASE (3)

.ds Aq ’

NAME

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

CONTENTS

VERSION

version 1.10

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,
            });

        # or if you require multiple databases at the same time
        $self->plugin(database, {
            databases => {
                db1 => {
                    dsn      => dbi:Pg:dbname=foo,
                    username => myusername,
                    password => mypassword,
                },
                db2 => {
                    dsn      => dbi:MySQL:dbname=bar,
                    username => othername,
                    password => otherpassword,
                },
            },
        });
    }



CONFIGURATION

    CONNECTING TO A SINGLE DATABASE

When connecting to a single database, the following configuration options are recognised:
’dsn’ should contain the DSN string required by DBI
’username’ the username that should be used to authenticate
’password’ the password that should be used to authenticate
’options’ options to pass to the DBD driver
’helper’ the name of the helper to associate with this database (default: db)
The only required option is ’dsn’, every other option is optional.

    CONNECTING TO MULTIPLE DATABASES

When you have the need to connect to multiple databases (or different RDBMS types), the following options are recognised:
’databases’ A hash reference whose key is the helper name, and the value is another hash reference containing connection options.

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. When using multiple databases, you also get multiple helpers.

AUTHOR

Ben van Staveren, <madcat at cpan.org>

BUGS/CONTRIBUTING

Please report any bugs or feature requests to through the web interface at <https://github.com/benvanstaveren/mojolicious-plugin-database/issues>. If you want to contribute changes or otherwise involve yourself in development, feel free to fork the Git repository from <https://github.com/benvanstaveren/mojolicious-plugin-database/>.

SUPPORT

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



    perldoc Mojolicious::Plugin::Database



You can also look for information at:
o AnnoCPAN: Annotated CPAN documentation

<http://annocpan.org/dist/Mojolicious-Plugin-Database>

o CPAN Ratings

<http://cpanratings.perl.org/d/Mojolicious-Plugin-Database>

o Search CPAN

<http://search.cpan.org/dist/Mojolicious-Plugin-Database/>

ACKNOWLEDGEMENTS

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

alabamapaul (github) for fixing the tests to work on Windows.

Babatope Aloba for pointing out it’d be really useful to be able to connect to multiple databases at once.

LICENSE AND COPYRIGHT

Copyright 2011-2015 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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MOJOLICIOUS::PLUGIN::DATABASE (3) 2015-09-25

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.