Thursday, November 02, 2006

Very Simple Wrapper for Perl DBI

I've released a new Perl module: DBIx::Wrapper::VerySimple which provides a very simple (object-oriented) wrapper around DBI.

DBIx::Wrapper::VerySimple provides three methods that between them cover about 98% of the SQL calls I've seen in Perl code over the years:
  • fetch_all() - run a SQL statement (typically a SELECT statement) and get back an arrayref of hashrefs (one hashref for each result row.)

  • fetch_hash() - run a SQL statement (typically a SELECT statement) and get back a single hashref (for just one row.)

  • Do() - run a non-SELECT statement such as CREATE or DELETE.
DBIx::Wrapper::VerySimple will use bind-variables if you pass them as additional arguments to fetch_all(), fetch_hash() or Do().

DBIx::Wrapper::VerySimple also provides a get_args() method and a dbh() method. get_args() returns the arguments originally passed to new() so you can re-connect, etc. if need be. dbh() returns the raw DBI databse handle so you have ready access to all the features of DBI.

DBIx::Wrapper::VerySimple is available on the CPAN: http://search.cpan.org/dist/DBIx-Wrapper-VerySimple/

Technorati tags: CPAN, DBI, Perl

No comments: