chexmix has asked for the wisdom of the Perl Monks concerning the following question:
Where I work we have a set of Perl scripts that access a small number of Sybase databases in order to do various things (usually to return a result set). There isn't a huge range of needs here - in fact the routines are almost all similar enough that I've been asked to abstract them out into an OO Perl module so that our code can be more efficient and uniform going forward.
To put it bluntly, I'm kind of lost. I I'd gotten to the point where I had a (sort of working) module that made use of SQL::Abstract, but then hit a wall when it appeared SQL::Abstract didn't handle "group by."
So I went looking for something to replace SQL::Abstract, and ran smack into DBIx::Class.
Thing is, DBIx::Class is (or seems to be) ginormous, & what with me being a newbie to module writing and OO Perl, I kinda ... can't see what the best way into that particular castle might be. In fact there is so much to DBIx::Class that I'm wondering whether it isn't overkill for a little local-use module like I want to write.
FWIW, the wishlist for the module is as follows:
- open a DBI connection given a hostname, database, username and password;
- prompt the user (if in an interactive context) for any of the four things above if missing;
- supply a method for preparing a query;
- supply a method for executing a prepared query;
- allow the user to just call DBModule::run_query("select ... from ... where ...") and expect the module to properly prepare/execute, while helpfully handling / trapping Sybase error codes
- supply a method to reformat the result set into various hashes/arrays
- supply a method to release a result set (equiv to $sth->finish()
- for any of the above, return a handle to a database, query handler, result set, whatever is appropriate.
So there you have it. As previously stated, I am newish to module writing and am feeling lost. Is looking at something like DBIx::Class the Right Thing to do here? & if it is, what's the best way to start?
I confess that I often feel so unskilled that I don't even know how to ask the right questions.
Thanks for any Words of Monkish Wisdom.