[Dbix-class] A problem with Postgres schemas
Ash Berlin
ash at cpan.org
Thu Dec 28 21:13:11 GMT 2006
Kevin Esteb wrote:
> I new to DBIx::Class, so please bear with me.
>
> I am running RHEL4 and have a postgres database with a schema named
> "analog". The DBIx::Class modules are the latest and greatest from CPAN,
> so is the DBD and the DBI for postgres. When I run the below code, I get
> this error:
>
> DBIx::Class::Schema::resultset(): Can't find source for analog.master at
> test9.pl line 28
>
> What is the proper way to access another database schema within
> postgres.
>
> Thanks
>
>
> package Test::Schema;
> use base qw/ DBIx::Class::Schema /;
>
> __PACKAGE__->load_classes();
>
> 1;
>
> package Test::Schema::Master;
> use base qw/ DBIx::Class /;
>
> __PACKAGE__->load_components(qw/ PK::Auto Core /);
> __PACKAGE__->table('analog.master');
> __PACKAGE__->add_columns(qw/ hostname datetime did /);
> __PACKAGE__->set_primary_key('hostname');
>
> 1;
>
> package Test;
>
> my $dsn = 'dbi:Pg:dbname=monitor';
> my $username = 'postgres';
> my $password = '';
> my $params = {RaiseError => 1, AutoCommit => 0};
>
> eval {
>
> my $schema = Test::Schema->connect($dsn, $username, $password,
> $params);
> my @masters = $schema->resultset('analog.master')->search();
>
> foreach my $master (@masters) {
>
> print "$master->hostname, $master->datetime, $master->did\n";
>
> }
>
> }; if ($@) { print "$@\n"; }
>
> 1;
>
Wrong moniker - it should be ->resultset('Master')
Where did you get the idea that it should be table name?
Ash
More information about the Dbix-class
mailing list