[CDBI] Mocking CDBI classes

David Baird lists.riverside at gmail.com
Tue Sep 27 23:23:57 BST 2005

On 9/27/05, William Ross <will at spanner.org> wrote:

> I like the question, though. I hate building sqlite databases just to
> run tests, with all the nasty MakeFile hacking that inevitably
> follows. Ideally I'd like there to be a standard cdbi test database
> included in the distribution and available to everyone. Then we could
> all use that.

Hmm, Devel::Maypole does that. It installs a simple set of sql files
and whips up a SQLite db in a temp file and gives you back a
connection string. You can ignore the Maypole bits.

In a test script:

use Devel::Maypole qw/ :test :find /;

# build a db from Devel::Maypole's 'default' resource kit
my $ddl    = find_ddl( 'Devel::Maypole', 'default' );
my $data = find_data( 'Devel::Maypole', 'default' );

my $dsn = database( ddl  => "$ddl/beerdb.simple.sql",
                                    data => "$data/beerdb.simple.sql",

I'm planning to package more SQL kits Real Soon Now. You can also use
it to install  and load your own resource kits.

Installation is a PITA if you are missing any dependencies - it tries
to use itself to install the SQL files :-( So you'd need to install
the deps first, the cpan shell won't do it. A Better Way is in the


More information about the ClassDBI mailing list