in reply to lost in my first Perl module
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.