Looking at your wish list, you're not abstracting anything away at all. You're just adding a needless layer.

open a DBI connection given a hostname, database, username and password;

DBI->connect

the user (if in an interactive context) for any of the four things above if missing;

Bad idea. Data storage and user interaction are unrelated tasks.

supply a method for preparing a query;

$dbh->prepare

supply a method for executing a prepared query;

$sth->execute

allow the user to just call DBModule::run_query("select ... from ... where ...") and expect the module to properly prepare/execute

If $dbh->prepare + $sth->execute is really a hardship,

sub do_select { my($dbh, $statement, $attr, @bind_values) = @_; my $sth = $dbh->prepare($statement, $attr) or return undef; $sth->execute(@bind_values) or return undef; return $sth; }

while helpfully handling / trapping Sybase error codes

RaiseError => 1

supply a method to reformat the result set into various hashes/arrays

$dbh->selectall_*

supply a method to release a result set (equiv to $sth->finish()

$sth->finish, though rarely needed.


In reply to Re: lost in my first Perl module by ikegami
in thread lost in my first Perl module by chexmix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.