NAME
    DBIx::Conn::MySQL - Shortcut to connect to MySQL database

VERSION
    This document describes version 0.001 of DBIx::Conn::MySQL (from Perl
    distribution DBIx-Conn-MySQL), released on 2018-07-02.

SYNOPSIS
    In the command-line, instead of:

     % perl -MDBI -E'my $dbh = DBI->connect("dbi:mysql:database=mydb", "someuser", "somepass"); $dbh->selectrow_array("query"); ...'

    or:

     % perl -MDBIx::Connect::MySQL -E'my $dbh = DBI->connect("dbi:mysql:database=mydb"); $dbh->selectrow_array("query"); ...'

    you can just:

     % perl -MDBIx::Conn::MySQL=mydb -E'$dbh->selectrow_array("query"); ...'

    To connect with some DBD::mysql parameters:

     % perl -MDBIx::Conn::MySQL='database=mydb;host=192.168.1.10;port=23306' -E'$dbh->selectrow_array("query"); ...'

    To change the exported database variable name from the default '$dbh'

     % perl -MDBIx::Conn::MySQL=mydb,'$handle' -E'$handle->selectrow_array("query"); ...'

    To supply username and password:

     % perl -MDBIx::Conn::MySQL=mydb,myuser,mysecret -E'$handle->selectrow_array("query"); ...'

DESCRIPTION
    This module offers some saving in typing when connecting to a MySQL
    database using DBI, and is particularly handy in one-liners. First, it
    uses DBIx::Connect::MySQL to connect so you don't have to supply
    username and password if you have configuration file (e.g. ~/.my.cnf);
    that module will search the username and password from configuration
    files.

    Second, it automatically "connect()" and exports the database handle
    $dbh for you.

    You often only have to specify the database name in the import argument:

     -MDBIx::Conn::MySQL=mydb

    This will result in the following DSN:

     DBI:mysql:database=mydb

    If you need to specify other parameters in the DSN, e.g. when the "host"
    is not "localhost", or the "port" is not the default port, you can
    specify that in the first import argument too (note the quoting because
    the shell will interpret ";" as command separator). When the first
    import argument contains "=", the module knows that you want to specify
    DSN parameters:

     -MDBIx::Conn::MySQL='mydb;host=192.168.1.10;port=23306'

    this will result in the following DSN:

     'DBI:mysql:database=mydb;host=192.168.1.10;port=23306

    If you want to use another variable name other than the default $dbh for
    the database handle, you can specify this in the second import argument
    (note the quoting because otherwise the shell will substitute with shell
    variable):

     -MDBIx::Conn::MySQL=mydb,'$handle'

    Lastly, if you want to supply username and password anyway, you can do
    that via the third and fourth import arguments (or the second and third
    import arguments, as long as the username does not begin with "$"):

     -MDBIx::Conn::MySQL=mydb,'$handle',myuser,mysecret
     -MDBIx::Conn::MySQL=mydb,myuser,mysecret

    But note that specifying passwords on the command-line is not
    recommended (hence the use of DBIx::Connect::MySQL in the first place).

HOMEPAGE
    Please visit the project's homepage at
    <https://metacpan.org/release/DBIx-Conn-MySQL>.

SOURCE
    Source repository is at
    <https://github.com/perlancar/perl-DBIx-Conn-MySQL>.

BUGS
    Please report any bugs or feature requests on the bugtracker website
    <https://rt.cpan.org/Public/Dist/Display.html?Name=DBIx-Conn-MySQL>

    When submitting a bug or request, please include a test-file or a patch
    to an existing test-file that illustrates the bug or desired feature.

AUTHOR
    perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE
    This software is copyright (c) 2018 by perlancar@cpan.org.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

