NAME
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.
VERSION
This document describes DBIx::ParseDSN::Default version 0.9.3
SYNOPSIS
## 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"
DESCRIPTION
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.
DSN ATTIRIBUTES
database
dbname
db
Database attribute of the DSN. See "names_for_database".
host
server
Server address of the connection. If any. See "names_for_host".
port
Port to connect to on the server. See "names_for_port"
OTHER METHODS
parse( $dsn )
A method used internally. Parses the DSN.
driver_attr
Any attributes to the driver, ie foo=bar in dbi:SQLite(foo=bar):db.sqlite. See "parse_dsn" in DBI.
driver_dsn
The 3rd part of the dsn string which is driver specific.
dsn_parts
The 5 values returned by DBI->parse_dsn
is_local
True if the dsn is local. File based db drivers are local, and network connections to localhost or 127.0.0.1 are local.
is_remote
The oposite of is_local
names_for_database
Name variations for the database attribute. This class uses qw/database dbname db/.
names_for_host
Name variations for the host attribute. This class uses qw/host server/.
names_for_port
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
.
known_attribute_hash
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.
dbd_driver
The perl module driver for this specific dsn. Currently the 2nd value of the dsn string prefixed by DBD:: , ie DBD::SQLite.
BUGS AND LIMITATIONS
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.
SEE ALSO
AUTHOR
Torbjørn Lindahl <torbjorn.lindahl@gmail.com>
LICENCE AND COPYRIGHT
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.
DISCLAIMER OF WARRANTY
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.