[Catalyst] DBIC connecting to remote MySQL

Dan dan at entropy.homelinux.org
Sun May 23 13:39:12 GMT 2010

Hi Robert. Thanks for the response :) Comments inline.

On Sun, 2010-05-23 at 07:50 -0500, Robert Wohlfarth wrote:

> On Sun, May 23, 2010 at 6:38 AM, Dan <dan at entropy.homelinux.org>
> wrote:
>         __PACKAGE__->config(
>            schema_class => 'EasySaver',
>            connect_info => {
>                dsn => 'dbi:mysql:dbname=EasySaver;host=archeopteryx',
>                user => 'username',
>                password => 'password',
>                AutoCommit => q{1},
>            }
>         );
> [snip...] 
>         Couldn't load class (EasySaver) because: Couldn't instantiate
>         component
>         "EasySaver::Model::ESDB", "Attribute (schema_class) does not
>         pass the
>         type constraint because: Validation failed for
>         'Catalyst::Model::DBIC::Schema::Types::SchemaClass' failed
>         with value
>         EasySaver
>         at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/Attribute.pm line 746
> You may want to try a different "schema_class". When you generated the
> model, it should also have created a "Schema.pm" file. Put that
> package name (not file name, the package name) in "schema_class". At
> least, this is what worked in my setup.

Interesting. I *didn't* get a Schema.pm file when I generated the model.
I don't know what this file is for, but if it has info on the schema,
then maybe this didn't get generated because the args I supplied to the
create script weren't sufficient for connecting ( as per my original
post ... no docs on accessing remote databases ). I tried regenerating
( without first deleting ) the model:

dan at sabayon:~/src/EasySaver$ script/easysaver_create.pl model ESDB
DBIC::Schema EasySaver dbi:mysql:EasySaver:archeopteryx 'username'
'password' '{ AutoCommit => 1 }'
 exists "/home/dan/src/EasySaver/script/../lib/EasySaver/Model"
 exists "/home/dan/src/EasySaver/script/../t"
 exists "/home/dan/src/EasySaver/script/../lib/EasySaver/Model/ESDB.pm"
 exists "/home/dan/src/EasySaver/script/../t/model_ESDB.t"
dan at sabayon:~/src/EasySaver$ 

So there's no attempt to create a Schema.pm file on this attempt either.
> I say that because of the error message. The first paragraph of output
> contains the actual error message. The rest of that is a stack trace
> that you don't need for this issue.
> Catalyst uses something called "Moose". Moose adds shortcuts for
> quickly building object oriented packages. It's very cool stuff. Moose
> offers limited type checking. Moose reported a mis-match in the type
> it expected versus the type it received.
> "schema_class" eventually becomes an object attribute. Moose thinks
> that "schema_class" should be set to an instance of type
> "Catalyst::Model::DBIC::Schema::Types::SchemaClass". The "EasySchema"
> from the configuration file is not from the Catalyst::Model::DBIC
> hierarchy. 
> -- 
> Robert Wohlfarth

Thanks for the explanation.


More information about the Catalyst mailing list