Perl-Sensitive Sunglasses | |
PerlMonks |
Re^2: Moose::Role to provide DBI interfaceby nysus (Parson) |
on Feb 08, 2017 at 20:48 UTC ( [id://1181457]=note: print w/replies, xml ) | Need Help?? |
My objectives here are 1) less typing to set up a $dbh and 2) get practice with Moose. Just about 100% of the time my scripts are for my own purposes. So I have this role set up with defaults that I will probably use 99% of the time. I can always change them later if I need to. So now I can write one liner like this:
LaborData::Data::SchemaLoader contains DBIx make_schema method and my DB package which automatically loads a database handler. And so now I never have to look up the code again for loading a schema for DBIx when I want to do it on a different database. But you are right. It's doubtful I would ever need to have my object switch the db connection. This didn't smell good to me either. That's why, I suppose, I asked this question. I like your suggestion of a configuration file. That does seem like the proper, more extensible way of doing things. I'm sure there's a module for that. But I got enough on my plate already. :) Thanks for the feedback.
$PM = "Perl Monk's";
In Section
Seekers of Perl Wisdom
|
|