#!/usr/bin/perl use warnings; use strict; use lib qw(./lib); use DBIx::Class::Prototyper; # create & populate in-memory tables # create & load in-memory DBIC classes & relationships # my $loader = DBIx::Class::Prototyper->new( \*DATA ); my $schema = $loader->connect_and_execute( 'dbi:SQLite:' ); # test a DBIC three-table join # on success, create module files for the DBIC classes & relationships # if( 'Beat It' eq $schema->resultset ( 'Artist' )->find( {name=>'Michael Jackson'} )->get_Cd->search_related ( 'get_Track' )->next->title ){ print "ok\n"; $loader->save_schema_as_module( 'My::Music' => 'MyMusic.pm' ); } __DATA__ CREATE TEMPORARY TABLE Artist ( id INTEGER PRIMARY KEY, name TEXT NOT NULL ); CREATE TEMPORARY TABLE Cd ( id INTEGER PRIMARY KEY, artist_id INTEGER NOT NULL REFERENCES Artist(id), title TEXT NOT NULL ); CREATE TEMPORARY TABLE Track ( id INTEGER PRIMARY KEY, cd_id INTEGER NOT NULL REFERENCES Cd(id), title TEXT NOT NULL ); INSERT INTO artist VALUES (1,'Michael Jackson'); INSERT INTO cd VALUES (1,1,'Thriller'); INSERT INTO track VALUES (1,1,'Beat It');