X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=examples%2FSchema%2Finsertdb.pl;h=4fb22fa590b8de3105590e1a9599281bd61103c9;hb=616ca57f8cd27f475da275bbef986fdd42d4069f;hp=67a432f05f42deefb2c58f08f1adc77dbc88389d;hpb=3d9632fd77404b25649fcda4d09999ca1778db87;p=dbsrgits%2FDBIx-Class.git diff --git a/examples/Schema/insertdb.pl b/examples/Schema/insertdb.pl old mode 100644 new mode 100755 index 67a432f..4fb22fa --- a/examples/Schema/insertdb.pl +++ b/examples/Schema/insertdb.pl @@ -1,13 +1,14 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl -use MyDatabase::Main; use strict; +use warnings; -my $schema = MyDatabase::Main->connect('dbi:SQLite:db/example.db'); +use MyApp::Schema; +use DBIx::Class::_Util 'parent_dir'; -# here's some of the sql that is going to be generated by the schema -# INSERT INTO artist VALUES (NULL,'Michael Jackson'); -# INSERT INTO artist VALUES (NULL,'Eminem'); +my $db_fn = parent_dir( $INC{'MyApp/Schema.pm'} ) . '../db/example.db'; + +my $schema = MyApp::Schema->connect("dbi:SQLite:$db_fn"); my @artists = (['Michael Jackson'], ['Eminem']); $schema->populate('Artist', [ @@ -30,7 +31,7 @@ foreach my $lp (keys %albums) { } $schema->populate('Cd', [ - [qw/title artist/], + [qw/title artistid/], @cds, ]); @@ -54,6 +55,6 @@ foreach my $track (keys %tracks) { } $schema->populate('Track',[ - [qw/cd title/], + [qw/cdid title/], @tracks, ]);