Skip to content

Instantly share code, notes, and snippets.

@issm
Created September 29, 2010 04:19
Show Gist options
  • Save issm/602285 to your computer and use it in GitHub Desktop.
Save issm/602285 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
package My::DB;
# default setting
my $setup = +{
dsn => 'dbi:mysql:test',
username => 'user',
password => 'passwd',
};
sub import {
my ($class, %opts) = @_;
$setup = $opts{setup} if defined $opts{setup};
}
eval << '...';
use DBIx::Skinny setup => $setup;
...
1;
package My::DB::Schema;
use base qw/DBIx::Skinny::Schema::Loader/;
use DBIx::Skinny::Schema;
__PACKAGE__->load_schema;
1;
__END__
# デフォルト設定で接続
use My::DB;
# 設定を指定して接続
use My::DB setup => +{
dsn => 'dbi:mysql:other_test',
username => 'other_user',
password => 'other_passwd',
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment