Created
April 11, 2012 16:27
-
-
Save tron1point0/2360363 to your computer and use it in GitHub Desktop.
Connect to dancer's dev DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use v5.14; | |
use warnings; | |
use YAML::XS qw(Load); | |
my @files = qw(config.yml environments/development.yml); | |
unshift @files, @ARGV if @ARGV; | |
for (@files) { | |
next unless -r; | |
eval { | |
my $contents = do {open my $h, '<', $_; local $/; <$h>}; | |
my %db = %{Load($contents)->{plugins}{Database}} or die; | |
%db = %{$db{connections}{(keys $db{connections})[0]}} if defined $db{connections}; | |
exec 'mysql', '-u', $db{username}, "-p$db{password}", '-h', $db{host}, $db{database}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment