Mojo::MySQL5::URL - Connection URL
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->options; # Build my $url = Mojo::MySQL5::URL->new; $url->scheme('mysql'); $url->userinfo('sri:foobar'); $url->host('server'); $url->port(3306); $url->database('test'); $url->options(foo => 'bar'); say "$url";
Mojo::MySQL5::URL implements MySQL Connection string URL for using in Mojo::MySQL5.
Mojo::MySQL5::URL inherits all attributes from Mojo::URL and implements the following new ones.
my $db = $url->database; $url = $url->database('test');
Database name.
my $options = $url->options; $url = $url->options->{PrintError} = 1;
Database options.
my $password = $url->password; $url = $url->password('s3cret');
Password part of URL.
my $username = $url->username; $url = $url->username('batman');
Username part of URL.
Mojo::MySQL5::URL inherits all methods from Mojo::URL and implements the following new ones.
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.
$url->parse('mysql://server:3000/test');
Parse URL string.
my $url = Mojo::MySQL5::URL->new; $url->parse('mysql://server:3000/test'); my $url = Mojo::MySQL5::URL->new('mysql://server:3000/test');
Mojo::MySQL5, Mojo::URL.
To install Mojo::MySQL5, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::MySQL5
CPAN shell
perl -MCPAN -e shell install Mojo::MySQL5
For more information on module installation, please visit the detailed CPAN module installation guide.