Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: DBI vs DBIx::Recordset vs princepawn vs chromatic

by chromatic (Archbishop)
on Mar 08, 2001 at 01:25 UTC ( #62833=note: print w/replies, xml ) Need Help??

in reply to DBI vs DBIx::Recordset vs princepawn vs chromatic

I would like to clear up one thing, before I respond. I had no knowledge that my e-mail to the editors of would be reproduced in their newsletter. In fact, until another monk mentioned that it quoted me, I was not even aware of the existence of that newsletter. (While I'm not thrilled about having a paragraph bereft of context, I'd be less thrilled if the entire e-mail had appeared, verbatim, without my permission.) Without that context, one would have to use the late unlamented PSI::ESP to discern whether I called for anyone's head on a platter or even asked for the opportunity to explain some tips and tricks to make DBI usage easier (and hopefully enlighten less-experienced programmers).

In fact, I did neither.

That said, I believe there are two issues here. I do not disagree that DBIx::Recordset and Class::Tangram and other modules are useful. But this whole discussion boils down to:

  • "mixing the generic application-level functionality of SQL generation with the specifics of the data about to be inserted"
  • poor examples of DBI usage

As for the first, I do not fully understand what you mean. At some point, your program must request information from the database. Something must decide to select certain rows from a particular table. If you mean that the field names should not be hardcoded in the generated SQL statement, I heartily agree. But your example is contrived, and the case is not nearly as bad as you make it seem. A reasonably experienced programmer can tell the difference between a hundred-line throwaway script and a program designed to be used continually. A decent programmer should be able to write a wrapper subroutine for the insert operation in less than five minutes. (DBIx::Recordset looks to be useful for reducing this burden, in the few minutes I've perused its documentation. I do not know if it provides a mechanism to work with anything other than a hash, which would cramp my style somewhat.)

In your meditation above, you say "you can make use of the Perl language to come up with more succinct ways to use DBI." That is my point exactly! If your example code is such a minefield, why not take the opportunity to show a better way to do it? That would do much more good than to leave readers with the impression that DBI is too difficult to use correctly. DBI has mechanisms to quote data automatically, and Perl has mechanisms which allow you to insert the data in any order. Those are two examples of things DBI provides for that your examples did not use -- and claimed were deficiencies of DBI.

In short, I think your advocacy would have been improved by using idiomatic code to illustrate otherwise valid issues with the DBI.

Update: Improved the formatting slightly.

  • Comment on Re: DBI vs DBIx::Recordset vs princepawn vs chromatic

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2021-01-15 21:20 GMT
Find Nodes?
    Voting Booth?