Skip to content

Instantly share code, notes, and snippets.

@tron1point0
Created April 11, 2012 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tron1point0/2360363 to your computer and use it in GitHub Desktop.
Save tron1point0/2360363 to your computer and use it in GitHub Desktop.
Connect to dancer's dev DB
#!/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