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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.