Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.


In reply to 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":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-29 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found