Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

writing DBI applications offline

by SilasTheMonk (Chaplain)
on Oct 06, 2008 at 07:29 UTC ( #715518=perlquestion: print w/replies, xml ) Need Help??

SilasTheMonk has asked for the wisdom of the Perl Monks concerning the following question:

I need to write an application with DBI and DBD::mysql and I am quite confident about how to do that. However in order to maximize my coding time I need to be able to do it offline. What is the best module to use as a substitute? DBD::Sponge, File, CSV? There will likely be about 5 or six tables. I had a look through CPAN but I could not really decide.

Replies are listed 'Best First'.
Re: writing DBI applications offline
by Corion (Pope) on Oct 06, 2008 at 07:31 UTC

    What SQL features do you need? I'm quite fond of DBD::SQLite (respectively the more maintained DBD::SQLite::Amalgamation distribution), which is a full, self-contained RDBMS in a single file.

Re: writing DBI applications offline
by moritz (Cardinal) on Oct 06, 2008 at 07:44 UTC
    Why not simply install a mysql server on your machine? On Debian it's a aptitude install mysql-server-5.0 away, and I guess other systems don't make it more complicated (on windows you'll probably have to find the installer binary yourself).

    Then you need a bit of configuration, but it's really not much, and then you can use the same DBD module on your local machine as on the production site. Which can be very important if things like UTF-8 handling are different than in other drivers.

      With a reddening face, Silas the Monk realizes he actually has a copy of mysql that can be installed. He apologises profusely to the assembled masters and bows obsequeiously. As he backs out of the room, he knocks over the umbrella stand.
Re: writing DBI applications offline
by andreas1234567 (Vicar) on Oct 06, 2008 at 08:17 UTC
    Consider Test::MockDBI. It allows you to test and run your application without having an actual, populated database present. See also this article from 2005 on (Note: article author eq module author).
    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
Re: writing DBI applications offline
by GrandFather (Saint) on Oct 06, 2008 at 07:32 UTC

    Is DBD::SQLite close enough for test purposes? It's easy to install and use.

    Perl reduces RSI - it saves typing
Re: writing DBI applications offline
by rhesa (Vicar) on Oct 06, 2008 at 11:45 UTC
    I recently had great success with DBD::Mock. Have a look.
Re: writing DBI applications offline
by dragonchild (Archbishop) on Oct 07, 2008 at 13:11 UTC
    The canonical answers are DBD::Mock (for a more purist solution) and DBD::SQLite (for a more practical solution). DBIx::Class (the current "premier Perl ORM", whatever that means) uses DBD::SQLite for all of its testing needs. This means you have a huge corpus of prior art to work from.

    Note: DBD::SQLite implements a subset of ANSI SQL. This means that you will not be able to test things like triggers, views, stored procedures, etc. Nor will you be able to test usage of DBMS-specific functions or keywords (such as LIMIT, CONNECT BY, etc). For that, you will need to use DBD::Mock.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

      It seems Silas The Monk knocked over a few more umbrella stands as he bumbled around the monastery.

      First of during the installation process for mysql, the process somehow got cancelled just as it was going into the wizard part. After that nothing I tried made the wizard reappear.

      However I am mightily pleased with DBI::SQLite. Thanks everyone.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://715518]
Approved by GrandFather
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2021-11-30 19:25 GMT
Find Nodes?
    Voting Booth?

    No recent polls found