[Catalyst] basics of getting started with DBIx

Matt S Trout dbix-class at trout.me.uk
Sat Mar 18 15:00:00 CET 2006


Daniel McBrearty wrote:
> Hi people
> 
> Just trying to put together a test script to explore this package, but a 
> bit stuck with the basics ... I have a class Schema.pm 
> <http://Schema.pm> in my library:
> 
> package Schema;
> use base qw/DBIx::Class::Schema/;
> __PACKAGE__->load_classes(qw/ Translator /);
> 1;
> 
> then a subdir Schema containing Translator.pm <http://Translator.pm>
> 
> #package Translator;

package Schema::Translator;

> use base qw/DBIx::Class/;

__PACKAGE__->load_components(qw/Core/);

> __PACKAGE__->table('translators');
> __PACKAGE__->add_columns(qw/ name autotx lastcat lang email translations 
> lastuse /);
> __PACKAGE__->set_primary_key('name');
> 1;
> 
> and here's my code ...
> 
> use Voc::DB::Schema;
> use Voc::Config;
> use Data::Dumper;
> 
> my $dsn = $Config::cfg->{'sqldb'};
> my $u = $Config::cfg->{'sqluser'};
> my $p = $Config::cfg->{'sqlpass'};
> my $attrs; # what should/can this be?

     # Whatever you'd pass to DBI->connect - AutoCommit, RaiseError etc.

> #Voc::DB::Schema->connect($dsn, $u, $p, $attrs);

my $schema = Voc::DB::Schema->connect($dsn, $u, $p, $attrs);

> now when I run I get :
> 
> Can't locate object method "result_source_instance" via package 
> "Schema::Translator" (perhaps you forgot to load "Schema::Translator"?) 
> at /usr/local/share/perl/5.8.7/DBIx/Class/Schema.pm line 70.
> 
> Seems the load isn't working? Why? Is my layout of files and modules 
> correct?

Corrections inline above :)

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list