Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Switch from DBI to DBIx::Class: thoughts?

by Your Mother (Archbishop)
on Mar 17, 2009 at 06:08 UTC ( [id://751100]=note: print w/replies, xml ) Need Help??


in reply to Switch from DBI to DBIx::Class: thoughts?

My feedback about whether you should: Hells yeah!

On a more sober note: If your DB layout is clean then you definitely should. If your data is messy and the sort of stuff that makes DB admins cringe then maybe not. Over the years the *only* things I have seen go on the mailing list with no good answers were because the underlying data design was fscked and something designed for clean, correct data design like DBIC just isn't set up to meet it in the middle.

There is much more to be gained that simple object abstraction of a row. There's inflation, deflation, serialization, automatic adjunct/auxiliary data generation, validation, schema versioning, x-platform deployment, automatic fixtures, testing, resultset chaining, and more.

To do legacy stuff: I'd auto-generate a DBIC schema (Result:: and ResultSet:: namespaces, which isn't in all the docs because it's pretty new but it rules). Then just give new code a shot via the new DBIC schema. Setting it up is trivial; here's a semi-tested snippet-

use DBIx::Class::Schema::Loader "make_schema_at"; die "Give DB connection args! E.g.:\n", " dbi:mysql:someTable user password \n", " 'dbi:mysql:moo_moo;mysql_read_default_file=~/.my.cnf'\ +n" unless @ARGV; $ARGV[3] = { quote_char => "`" }; # Useful tidbit not (obvious) in the + docs. make_schema_at( $insert_schema_class, { components => [qw( SomethingYouUse )], quote_char => "`", dump_directory => $target_lib, use_namespaces => 1, }, \@ARGV );

Then go with it for the next little something-something and see if it's fun or a drag. :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 21:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found