DBIx::ParseDSN::Default - A default DSN parser, moose based. You can use this as is, or subclass it. DBIx::ParseDSN uses this class unless it finds a better parser.
It can be used directly to parse a DSN, but use instead "parse_dsn" in DBIx::ParseDSN which is the intended way to achieve this.
This document describes DBIx::ParseDSN::Default version 0.9.3
## Use it directly: use DBIx::ParseDSN::Default; my $dsn = DBIx::ParseDSN::Default->new( "dbi:Foo:/bar/baz" ); ## Subclass: { package DBIx::ParseDSN::OddBall; use Moo; extends 'DBIx::ParseDSN::Default'; sub names_for_database{ return qw/bucket/ } } package main; use DBIx::ParseDSN; my $dsn = parse_dsn( "dbi:OddBall:bucket=foo" ) $dsn->database; ## "foo"
This is a default DSN parser. It is not specific to any driver. It can safely be used as a base for driver specfic parsers.
It handles the most common database drivers. See test files for details.
Database attribute of the DSN. See "names_for_database".
Server address of the connection. If any. See "names_for_host".
Port to connect to on the server. See "names_for_port"
A method used internally. Parses the DSN.
Any attributes to the driver, ie foo=bar in dbi:SQLite(foo=bar):db.sqlite. See "parse_dsn" in DBI.
The 3rd part of the dsn string which is driver specific.
The 5 values returned by DBI->parse_dsn
True if the dsn is local. File based db drivers are local, and network connections to localhost or 127.0.0.1 are local.
The oposite of is_local
Name variations for the database attribute. This class uses qw/database dbname db/.
Name variations for the host attribute. This class uses qw/host server/.
Name variations for the port attribute. This class uses port. This is included for completeness to follow the pattern used for database and host but is likely never to be anything other than just port.
port
database
host
Combines information for the three above methods to compose a hash useful for translating names, eg:
( database => "database", dbname => "database", db => "database", server => "host", hostname => "host", )
This method is mainly for internal use.
The perl module driver for this specific dsn. Currently the 2nd value of the dsn string prefixed by DBD:: , ie DBD::SQLite.
No bugs have been reported.
Please report any bugs or feature requests to bug-bug-dbix-parsedsn::parser::default@rt.cpan.org, or through the web interface at http://rt.cpan.org.
bug-bug-dbix-parsedsn::parser::default@rt.cpan.org
DBIx::ParseDSN
Torbjørn Lindahl <torbjorn.lindahl@gmail.com>
<torbjorn.lindahl@gmail.com>
Copyright (c) 2014, Torbjørn Lindahl <torbjorn.lindahl@gmail.com>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
To install DBIx::ParseDSN, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::ParseDSN
CPAN shell
perl -MCPAN -e shell install DBIx::ParseDSN
For more information on module installation, please visit the detailed CPAN module installation guide.