[sf-perl] ORM vs. DBI

Kevin Frost biztos at mac.com
Tue Mar 1 09:26:39 PST 2011

I belatedly second the point in favor of DBIx::Class.  Not the easiest  
thing to learn but once you're up to speed it's very, very powerful.

And IIRC you can tweak the SQL if you feel the need, it's just not  
super simple.

There are also really good testing options.

For my money, I don't think I would do any serious development without  
at least enough ORM to permanetly avoid hashrefs and arrayrefs in the  
app code.

-- frosty

On 28.02.2011, at 18:02, Fred Moyer <fred at redhotpenguin.com> wrote:

> On Sat, Feb 26, 2011 at 11:00 PM, Michael Friedman
> <friedman at highwire.stanford.edu> wrote:
>> Fellow Perl Mongers,
>> I finally got around to reading up on and trying out DBIx::Class.  
>> It looks pretty neat, but after loading up a complex DB (108  
>> tables) and writing a short test script, I really don't understand  
>> why you'd want to use it over using just regular DBI and SQL. Maybe  
>> it's because I knew SQL before I knew Perl and I'm training in  
>> looking at things in a SQL way, but I'm not so sure.
>> So I'd like to throw the floor open to discussion. Why would you  
>> want to use DBIx::Class (or any Object-Relational Manager) instead  
>> of writing classes that call the DB directly through DBI?
> Once you understand how to use DBIx::Class, it makes your life a lot
> simpler.  You don't have to think about what fields you're retrieving
> with sql statements, whether or not you typed in the wrong key for a
> hash slice lookup, etc, etc.
> If writing raw sql with DBI is a sledgehammer, DBIx::Class is a
> wrecking ball.  It takes some review and time to learn the API, but
> you can get a lot more done in a much shorter amount of time, and
> still be able to use raw SQL for those queries you need to optimize.
> Best of all, you can point it at your database and have it extract a
> full resultset library from it, to which you can add your own methods.
> If making sure your sql is exactly the way you want it in every case,
> DBIx::Class is probably not for you.  But if you want to get business
> goals accomplished, and worry about optimizing thing later, it is a
> choice tool.
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm

More information about the SanFrancisco-pm mailing list