Good day, Monks -
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.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.