I think setting them with the methods is a better idea in general.

On Thu, Jul 16, 2015 at 11:54 AM, Richard Sugg <[email protected]>
wrote:

> I ran into an issue where the database user has a # character, and
> Mojo::mysql doesn't parse the uri like I expected. If I set the dsn,
> username, and password separately, it works. Should I be escaping the # in
> some way? Here's an example:
>
> my $user = 'user';
> my $pass = 'abc#def';
> my $host = 'host.domain';
> my $dbname = 'db';
>
> my $mysql = Mojo::mysql->new;
> my $uri = sprintf('mysql://%s:%s@%s/%s', $user, $pass, $host, $dbname);
> my $parsed = $mysql->from_string($uri);
> print "Given URI: $uri\n";
> print "Parsed:\n";
> print "  DSN: " . $mysql->dsn . "\n";
> print " User: " . $mysql->username . "\n";
> print " Pass: " . $mysql->password . "\n";
>
> $mysql->dsn("dbi:mysql:dbname=$dbname;host=$host");
> $mysql->username($user);
> $mysql->password($pass);
> print "Set manually:\n";
> print "  DSN: " . $mysql->dsn . "\n";
> print " User: " . $mysql->username . "\n";
> print " Pass: " . $mysql->password . "\n";
>
> produces
>
> Use of uninitialized value in concatenation (.) or string at
> /Users/risugg/.plenv/versions/5.20.2/lib/perl5/site_perl/5.20.2/Mojo/
> mysql.pm line 57.
> Given URI: mysql://user:abc#[email protected]/db
> Parsed:
> *  DSN: dbi:mysql:dbname=;host=user:abc*
>  User:
>  Pass:
> Set manually:
> *  DSN: dbi:mysql:dbname=db;host=host.domain*
>  User: user
>  Pass: abc#def
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to