Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Moose::Role to provide DBI interface

by nysus (Parson)
on Feb 08, 2017 at 20:48 UTC ( [id://1181457]=note: print w/replies, xml ) Need Help??


in reply to Re: Moose::Role to provide DBI interface
in thread Moose::Role to provide DBI interface

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:

use LaborData::Data::SchemaLoader; my $loader = LaborData::Data::SchemaLoader->new; $loader->make_schema('lm2_data');

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";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re^3: Moose::Role to provide DBI interface
by Anonymous Monk on Feb 08, 2017 at 20:52 UTC
    "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."

    This makes zero sense. Why would you "load" a schema? What does that even mean?

      Don't know for sure. Just learning DBIx. Apparently it generates a bunch of files that contain meta data about the database.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks

        Learn SQL first and learn how to create Entities and Relationships.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1181457]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-23 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found