NAME
Mojo::MySQL5::URL - MySQL Connection URL
SYNOPSIS
use Mojo::MySQL5::URL;
# Parse
my $url = Mojo::MySQL5::URL->new('mysql://sri:foo@server:3306/test?foo=bar');
say $url->username;
say $url->password;
say $url->host;
say $url->port;
say $url->database;
say $url->query;
# Build
my $url = Mojo::MySQL5::URL->new;
$url->scheme('mysql');
$url->userinfo('sri:foobar');
$url->host('server');
$url->port(3306);
$url->database('test');
$url->query(foo => 'bar');
say "$url";
DESCRIPTION
Mojo::MySQL5::URL implements MySQL Connection string URL for using in Mojo::MySQL5.
ATTRIBUTES
Mojo::MySQL5::URL inherits all attributes from Mojo::URL and implements the following new ones.
database
my $db = $url->database;
$url = $url->database('test');
Database name.
options
my $options = $url->options;
$url = $url->options->{PrintError} = 1;
Database options.
password
my $password = $url->password;
$url = $url->password('s3cret');
Password part of URL.
username
my $username = $url->username;
$url = $url->username('batman');
Username part of URL.
METHODS
Mojo::MySQL5::URL inherits all methods from Mojo::URL and implements the following new ones.
dsn
my $url = Mojo::MySQL5::URL->new('mysql://server:3000/test');
# dbi:mysql:dbname=test;host=server;port=3000
say $url->dsn;
Convert URL to DBI Data Source Name.
parse
$url->parse('mysql://server:3000/test');
Parse URL string.
new
my $url = Mojo::MySQL5::URL->new;
$url->parse('mysql://server:3000/test');
my $url = Mojo::MySQL5::URL->new('mysql://server:3000/test');