Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

DBIC connecting to remote MySQL

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


dan at entropy

May 23, 2010, 4:38 AM

Post #1 of 9 (1786 views)
Permalink
DBIC connecting to remote MySQL

Greetings.

I realise that this is slightly off-topic ... I tried to sign up to the
DBIC mailing list, but haven't received anything yet ( and have checked
spam filter ).

I'm trying to teach myself Catalyst. At the same time, I'm trying to get
my head around a whole heap of other things, eg MVC ( read about but not
used ), DBIC, JSON, JQuery ... more than I'd like to learn all at once
to be honest.

I can find *no* documentation on setting up a connection to a remote
MySQL server, anywhere.

I created a model with the _create.pl script, and edited the package
config thing to look like this:

__PACKAGE__->config(
schema_class => 'EasySaver',

connect_info => {
dsn => 'dbi:mysql:dbname=EasySaver;host=archeopteryx',
user => 'username',
password => 'password',
AutoCommit => q{1},
}
);

Doesn't work.

Also tried this:

__PACKAGE__->config(
schema_class => 'EasySaver',

connect_info => {
dsn => 'dbi:mysql:EasySaver',
host => 'archeopteryx',
user => 'EasySaver',
password => 'loaderup',
AutoCommit => q{1},
}
);

Also doesn't work.

When I try to start the server:

export DBIC_TRACE=1
script/easysaver_server.pl -r

... I get a MASSIVE stack trace, which I've pasted at the bottom of
this message.

Does anyone have a working example for specifying a server IP / hostname
for a MySQL connection?

Thanks :)

Dan

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

Moose::Meta::Attribute::_coerce_and_verify('Moose::Meta::Attribute=HASH(0x995cbb0)', 'EasySaver', 'EasySaver::Model::ESDB=HASH(0x9998ee0)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/Attribute.pm line 398

Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=HASH(0x995cbb0)', 'Moose::Meta::Instance=HASH(0x9a62198)', 'EasySaver::Model::ESDB=HASH(0x9998ee0)', 'HASH(0x9998a50)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Class.pm line 364

Class::MOP::Class::_construct_instance('Moose::Meta::Class=HASH(0x992c120)', 'HASH(0x9998a50)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Class.pm line 351
Class::MOP::Class::new_object('Moose::Meta::Class=HASH(0x992c120)',
'HASH(0x9998a50)') called
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/Class.pm line 255
Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x992c120)',
'HASH(0x9998a50)') called
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Object.pm line 25
Moose::Object::new('EasySaver::Model::ESDB', 'EasySaver',
'HASH(0x996c840)') called at generated method (unknown origin) line 3
Catalyst::Model::DBIC::Schema::new('EasySaver::Model::ESDB',
'EasySaver', 'HASH(0x996c840)') called
at /usr/lib/perl5/site_perl/5.10.1/MooseX/Traits/Pluggable.pm line 131
MooseX::Traits::Pluggable::new_with_traits('EasySaver::Model::ESDB',
'EasySaver') called
at /usr/lib/perl5/site_perl/5.10.1/CatalystX/Component/Traits.pm line
145
CatalystX::Component::Traits::COMPONENT('EasySaver::Model::ESDB',
'EasySaver', 'HASH(0x9a5eea0)') called
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 48
Class::MOP::Method::Wrapped::__ANON__('EasySaver::Model::ESDB',
'EasySaver', 'HASH(0x9a5eea0)') called
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 89
Catalyst::Model::DBIC::Schema::COMPONENT('EasySaver::Model::ESDB',
'EasySaver', 'HASH(0x9a5eea0)') called
at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line 2507
eval {...} called at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line
2507
Catalyst::setup_component('EasySaver', 'EasySaver::Model::ESDB') called
at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line 2421
Catalyst::setup_components('EasySaver') called
at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line 1143
Catalyst::setup('EasySaver') called
at /home/dan/src/EasySaver/script/../lib/EasySaver.pm line 42
require EasySaver.pm called
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
line 101
Class::MOP::__ANON__() called
at /usr/lib/perl5/site_perl/5.10.1/Try/Tiny.pm line 71
eval {...} called at /usr/lib/perl5/site_perl/5.10.1/Try/Tiny.pm line
67
Try::Tiny::try('CODE(0x95d4400)', 'Try::Tiny::Catch=REF(0x967ee90)')
called
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
line 110
Class::MOP::load_first_existing_class('EasySaver') called
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
line 121
Class::MOP::load_class('EasySaver') called
at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRole.pm line 61

Catalyst::ScriptRole::_run_application('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 144
Catalyst::Script::Server::__ANON__() called
at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter/Forking.pm line 20

Catalyst::Restarter::Forking::_fork_and_start('Catalyst::Restarter::Forking=HASH(0x95d5190)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter.pm line 80

Catalyst::Restarter::run_and_watch('Catalyst::Restarter::Forking=HASH(0x95d5190)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 178

Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 48

Class::MOP::Method::Wrapped::__ANON__('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 89

Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRunner.pm line 20
Catalyst::ScriptRunner::run('Catalyst::ScriptRunner', 'EasySaver',
'Server') called at script/easysaver_server.pl line 8"Compilation failed
in require
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
line 101.
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
line 105
Class::MOP::__ANON__('Couldn\'t instantiate component
"EasySaver::Model::ESDB", "At...') called
at /usr/lib/perl5/site_perl/5.10.1/Try/Tiny.pm line 98
Try::Tiny::try('CODE(0x95d4400)', 'Try::Tiny::Catch=REF(0x967ee90)')
called
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
line 110
Class::MOP::load_first_existing_class('EasySaver') called
at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
line 121
Class::MOP::load_class('EasySaver') called
at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRole.pm line 61

Catalyst::ScriptRole::_run_application('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 144
Catalyst::Script::Server::__ANON__() called
at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter/Forking.pm line 20

Catalyst::Restarter::Forking::_fork_and_start('Catalyst::Restarter::Forking=HASH(0x95d5190)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter.pm line 80

Catalyst::Restarter::run_and_watch('Catalyst::Restarter::Forking=HASH(0x95d5190)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 178

Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 48

Class::MOP::Method::Wrapped::__ANON__('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 89

Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRunner.pm line 20
Catalyst::ScriptRunner::run('Catalyst::ScriptRunner', 'EasySaver',
'Server') called at script/easysaver_server.pl line 8


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


will at serensoft

May 23, 2010, 5:21 AM

Post #2 of 9 (1754 views)
Permalink
Re: DBIC connecting to remote MySQL [In reply to]

Well I'm kinda new to Catalyst and the MVC world myself, and I would have
tried exactly what you've tried. So my small-time suggestion to you is to
try it with perl debugging on, and then use this to drop into single-step
mode somewhere prescient:

$DB::single = 1;

Then you
$ perl -d script/easysaver_server.pl
> c

In particular if you can figure out where it's going to get the database
connection established, right before then would be a great place for
$DB::single. :) Somewhere in there it's apparently treating things a bit
differently than normal DBI code... If you can step through that you'll
likely find out what's going on.

Hope this helps, at least a little... :)


On Sun, May 23, 2010 at 11:38 AM, Dan <dan [at] entropy> wrote:

> Greetings.
>
> I realise that this is slightly off-topic ... I tried to sign up to the
> DBIC mailing list, but haven't received anything yet ( and have checked
> spam filter ).
>
> I'm trying to teach myself Catalyst. At the same time, I'm trying to get
> my head around a whole heap of other things, eg MVC ( read about but not
> used ), DBIC, JSON, JQuery ... more than I'd like to learn all at once
> to be honest.
>
> I can find *no* documentation on setting up a connection to a remote
> MySQL server, anywhere.
>
> I created a model with the _create.pl script, and edited the package
> config thing to look like this:
>
> __PACKAGE__->config(
> schema_class => 'EasySaver',
>
> connect_info => {
> dsn => 'dbi:mysql:dbname=EasySaver;host=archeopteryx',
> user => 'username',
> password => 'password',
> AutoCommit => q{1},
> }
> );
>
> Doesn't work.
>
> Also tried this:
>
> __PACKAGE__->config(
> schema_class => 'EasySaver',
>
> connect_info => {
> dsn => 'dbi:mysql:EasySaver',
> host => 'archeopteryx',
> user => 'EasySaver',
> password => 'loaderup',
> AutoCommit => q{1},
> }
> );
>
> Also doesn't work.
>
> When I try to start the server:
>
> export DBIC_TRACE=1
> script/easysaver_server.pl -r
>
> ... I get a MASSIVE stack trace, which I've pasted at the bottom of
> this message.
>
> Does anyone have a working example for specifying a server IP / hostname
> for a MySQL connection?
>
> Thanks :)
>
> Dan
>
> 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
>
> Moose::Meta::Attribute::_coerce_and_verify('Moose::Meta::Attribute=HASH(0x995cbb0)',
> 'EasySaver', 'EasySaver::Model::ESDB=HASH(0x9998ee0)') called at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/Attribute.pm
> line 398
>
> Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=HASH(0x995cbb0)',
> 'Moose::Meta::Instance=HASH(0x9a62198)',
> 'EasySaver::Model::ESDB=HASH(0x9998ee0)', 'HASH(0x9998a50)') called at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Class.pm
> line 364
>
> Class::MOP::Class::_construct_instance('Moose::Meta::Class=HASH(0x992c120)',
> 'HASH(0x9998a50)') called at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Class.pm
> line 351
> Class::MOP::Class::new_object('Moose::Meta::Class=HASH(0x992c120)',
> 'HASH(0x9998a50)') called
> at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/Class.pm
> line 255
> Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x992c120)',
> 'HASH(0x9998a50)') called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Object.pm
> line 25
> Moose::Object::new('EasySaver::Model::ESDB', 'EasySaver',
> 'HASH(0x996c840)') called at generated method (unknown origin) line 3
> Catalyst::Model::DBIC::Schema::new('EasySaver::Model::ESDB',
> 'EasySaver', 'HASH(0x996c840)') called
> at /usr/lib/perl5/site_perl/5.10.1/MooseX/Traits/Pluggable.pm line 131
> MooseX::Traits::Pluggable::new_with_traits('EasySaver::Model::ESDB',
> 'EasySaver') called
> at /usr/lib/perl5/site_perl/5.10.1/CatalystX/Component/Traits.pm line
> 145
> CatalystX::Component::Traits::COMPONENT('EasySaver::Model::ESDB',
> 'EasySaver', 'HASH(0x9a5eea0)') called
> at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm
> line 48
> Class::MOP::Method::Wrapped::__ANON__('EasySaver::Model::ESDB',
> 'EasySaver', 'HASH(0x9a5eea0)') called
> at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm
> line 89
> Catalyst::Model::DBIC::Schema::COMPONENT('EasySaver::Model::ESDB',
> 'EasySaver', 'HASH(0x9a5eea0)') called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line 2507
> eval {...} called at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm
> line
> 2507
> Catalyst::setup_component('EasySaver', 'EasySaver::Model::ESDB')
> called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line 2421
> Catalyst::setup_components('EasySaver') called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line 1143
> Catalyst::setup('EasySaver') called
> at /home/dan/src/EasySaver/script/../lib/EasySaver.pm line 42
> require EasySaver.pm called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 101
> Class::MOP::__ANON__() called
> at /usr/lib/perl5/site_perl/5.10.1/Try/Tiny.pm line 71
> eval {...} called at /usr/lib/perl5/site_perl/5.10.1/Try/Tiny.pm
> line
> 67
> Try::Tiny::try('CODE(0x95d4400)', 'Try::Tiny::Catch=REF(0x967ee90)')
> called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 110
> Class::MOP::load_first_existing_class('EasySaver') called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 121
> Class::MOP::load_class('EasySaver') called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRole.pm line 61
>
> Catalyst::ScriptRole::_run_application('Catalyst::Script::Server=HASH(0x92d0248)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 144
> Catalyst::Script::Server::__ANON__() called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter/Forking.pm line 20
>
> Catalyst::Restarter::Forking::_fork_and_start('Catalyst::Restarter::Forking=HASH(0x95d5190)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter.pm line 80
>
> Catalyst::Restarter::run_and_watch('Catalyst::Restarter::Forking=HASH(0x95d5190)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 178
>
> Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)')
> called at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm
> line 48
>
> Class::MOP::Method::Wrapped::__ANON__('Catalyst::Script::Server=HASH(0x92d0248)')
> called at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm
> line 89
>
> Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRunner.pm line 20
> Catalyst::ScriptRunner::run('Catalyst::ScriptRunner', 'EasySaver',
> 'Server') called at script/easysaver_server.pl line 8"Compilation failed
> in require
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 101.
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 105
> Class::MOP::__ANON__('Couldn\'t instantiate component
> "EasySaver::Model::ESDB", "At...') called
> at /usr/lib/perl5/site_perl/5.10.1/Try/Tiny.pm line 98
> Try::Tiny::try('CODE(0x95d4400)', 'Try::Tiny::Catch=REF(0x967ee90)')
> called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 110
> Class::MOP::load_first_existing_class('EasySaver') called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 121
> Class::MOP::load_class('EasySaver') called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRole.pm line 61
>
> Catalyst::ScriptRole::_run_application('Catalyst::Script::Server=HASH(0x92d0248)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 144
> Catalyst::Script::Server::__ANON__() called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter/Forking.pm line 20
>
> Catalyst::Restarter::Forking::_fork_and_start('Catalyst::Restarter::Forking=HASH(0x95d5190)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter.pm line 80
>
> Catalyst::Restarter::run_and_watch('Catalyst::Restarter::Forking=HASH(0x95d5190)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 178
>
> Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)')
> called at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm
> line 48
>
> Class::MOP::Method::Wrapped::__ANON__('Catalyst::Script::Server=HASH(0x92d0248)')
> called at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm
> line 89
>
> Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRunner.pm line 20
> Catalyst::ScriptRunner::run('Catalyst::ScriptRunner', 'EasySaver',
> 'Server') called at script/easysaver_server.pl line 8
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>



--
will trillich
"It's only by saying 'no' that you can concentrate on the things that are
really important." -- Steve Jobs


rbwohlfarth at gmail

May 23, 2010, 5:50 AM

Post #3 of 9 (1740 views)
Permalink
Re: DBIC connecting to remote MySQL [In reply to]

On Sun, May 23, 2010 at 6:38 AM, Dan <dan [at] entropy> 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.

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<http://search.cpan.org/dist/Moose/lib/Moose/Manual.pod>".
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


dan at entropy

May 23, 2010, 6:08 AM

Post #4 of 9 (1757 views)
Permalink
Re: DBIC connecting to remote MySQL [In reply to]

Hi Will.

Thanks for the response. Interesting suggestion :) I have the perl
debugger with a passion :) Clunky damned thing. I'm using Eclipse with
the EPIC plugin, and ( at work ) Komodo. Anyway, I stepped through a bit
of code ( quite a bit ) before I got bored with this and tried something
else.

According to
http://search.cpan.org/~frew/DBIx-Class-0.08121/lib/DBIx/Class/Storage/DBI.pm ... you can replace the dsn / user / password args with a coderef that returns a DBI connection. Sweet!

So I did this, and *still* get the error below. Doh! I am 100% certain
my connection string is good. So I assume I have another issue.

Don't really know where to go from here ... apart from ye olde fashioned
debugger.

Dan

On Sun, 2010-05-23 at 12:21 +0000, will [at] serensoft wrote:
> Well I'm kinda new to Catalyst and the MVC world myself, and I would
> have tried exactly what you've tried. So my small-time suggestion to
> you is to try it with perl debugging on, and then use this to drop
> into single-step mode somewhere prescient:
>
>
> $DB::single = 1;
>
>
> Then you
> $ perl -d script/easysaver_server.pl
> > c
>
>
> In particular if you can figure out where it's going to get the
> database connection established, right before then would be a great
> place for $DB::single. :) Somewhere in there it's apparently treating
> things a bit differently than normal DBI code... If you can step
> through that you'll likely find out what's going on.
>
>
> Hope this helps, at least a little... :)
>
>
> On Sun, May 23, 2010 at 11:38 AM, Dan <dan [at] entropy>
> wrote:
> Greetings.
>
> I realise that this is slightly off-topic ... I tried to sign
> up to the
> DBIC mailing list, but haven't received anything yet ( and
> have checked
> spam filter ).
>
> I'm trying to teach myself Catalyst. At the same time, I'm
> trying to get
> my head around a whole heap of other things, eg MVC ( read
> about but not
> used ), DBIC, JSON, JQuery ... more than I'd like to learn all
> at once
> to be honest.
>
> I can find *no* documentation on setting up a connection to a
> remote
> MySQL server, anywhere.
>
> I created a model with the _create.pl script, and edited the
> package
> config thing to look like this:
>
> __PACKAGE__->config(
> schema_class => 'EasySaver',
>
> connect_info => {
> dsn => 'dbi:mysql:dbname=EasySaver;host=archeopteryx',
> user => 'username',
> password => 'password',
> AutoCommit => q{1},
> }
> );
>
> Doesn't work.
>
> Also tried this:
>
> __PACKAGE__->config(
> schema_class => 'EasySaver',
>
> connect_info => {
> dsn => 'dbi:mysql:EasySaver',
> host => 'archeopteryx',
> user => 'EasySaver',
> password => 'loaderup',
> AutoCommit => q{1},
> }
> );
>
> Also doesn't work.
>
> When I try to start the server:
>
> export DBIC_TRACE=1
> script/easysaver_server.pl -r
>
> ... I get a MASSIVE stack trace, which I've pasted at the
> bottom of
> this message.
>
> Does anyone have a working example for specifying a server
> IP / hostname
> for a MySQL connection?
>
> Thanks :)
>
> Dan
>
> 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
>
> Moose::Meta::Attribute::_coerce_and_verify('Moose::Meta::Attribute=HASH(0x995cbb0)', 'EasySaver', 'EasySaver::Model::ESDB=HASH(0x9998ee0)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/Attribute.pm line 398
>
> Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=HASH(0x995cbb0)', 'Moose::Meta::Instance=HASH(0x9a62198)', 'EasySaver::Model::ESDB=HASH(0x9998ee0)', 'HASH(0x9998a50)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Class.pm line 364
>
> Class::MOP::Class::_construct_instance('Moose::Meta::Class=HASH(0x992c120)', 'HASH(0x9998a50)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Class.pm line 351
>
> Class::MOP::Class::new_object('Moose::Meta::Class=HASH(0x992c120)',
> 'HASH(0x9998a50)') called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/Class.pm line 255
>
> Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x992c120)',
> 'HASH(0x9998a50)') called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Object.pm line 25
> Moose::Object::new('EasySaver::Model::ESDB',
> 'EasySaver',
> 'HASH(0x996c840)') called at generated method (unknown origin)
> line 3
>
> Catalyst::Model::DBIC::Schema::new('EasySaver::Model::ESDB',
> 'EasySaver', 'HASH(0x996c840)') called
> at /usr/lib/perl5/site_perl/5.10.1/MooseX/Traits/Pluggable.pm
> line 131
>
> MooseX::Traits::Pluggable::new_with_traits('EasySaver::Model::ESDB',
> 'EasySaver') called
> at /usr/lib/perl5/site_perl/5.10.1/CatalystX/Component/Traits.pm line
> 145
>
> CatalystX::Component::Traits::COMPONENT('EasySaver::Model::ESDB',
> 'EasySaver', 'HASH(0x9a5eea0)') called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 48
>
> Class::MOP::Method::Wrapped::__ANON__('EasySaver::Model::ESDB',
> 'EasySaver', 'HASH(0x9a5eea0)') called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 89
>
> Catalyst::Model::DBIC::Schema::COMPONENT('EasySaver::Model::ESDB',
> 'EasySaver', 'HASH(0x9a5eea0)') called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line 2507
> eval {...} called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line
> 2507
> Catalyst::setup_component('EasySaver',
> 'EasySaver::Model::ESDB') called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line 2421
> Catalyst::setup_components('EasySaver') called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst.pm line 1143
> Catalyst::setup('EasySaver') called
> at /home/dan/src/EasySaver/script/../lib/EasySaver.pm line 42
> require EasySaver.pm called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 101
> Class::MOP::__ANON__() called
> at /usr/lib/perl5/site_perl/5.10.1/Try/Tiny.pm line 71
> eval {...} called
> at /usr/lib/perl5/site_perl/5.10.1/Try/Tiny.pm line
> 67
> Try::Tiny::try('CODE(0x95d4400)',
> 'Try::Tiny::Catch=REF(0x967ee90)')
> called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 110
> Class::MOP::load_first_existing_class('EasySaver')
> called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 121
> Class::MOP::load_class('EasySaver') called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRole.pm line
> 61
>
> Catalyst::ScriptRole::_run_application('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 144
> Catalyst::Script::Server::__ANON__() called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter/Forking.pm line 20
>
> Catalyst::Restarter::Forking::_fork_and_start('Catalyst::Restarter::Forking=HASH(0x95d5190)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter.pm line 80
>
> Catalyst::Restarter::run_and_watch('Catalyst::Restarter::Forking=HASH(0x95d5190)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 178
>
> Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 48
>
> Class::MOP::Method::Wrapped::__ANON__('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 89
>
> Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRunner.pm line 20
> Catalyst::ScriptRunner::run('Catalyst::ScriptRunner',
> 'EasySaver',
> 'Server') called at script/easysaver_server.pl line
> 8"Compilation failed
> in require
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 101.
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 105
> Class::MOP::__ANON__('Couldn\'t instantiate component
> "EasySaver::Model::ESDB", "At...') called
> at /usr/lib/perl5/site_perl/5.10.1/Try/Tiny.pm line 98
> Try::Tiny::try('CODE(0x95d4400)',
> 'Try::Tiny::Catch=REF(0x967ee90)')
> called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 110
> Class::MOP::load_first_existing_class('EasySaver')
> called
> at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP.pm
> line 121
> Class::MOP::load_class('EasySaver') called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRole.pm line
> 61
>
> Catalyst::ScriptRole::_run_application('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 144
> Catalyst::Script::Server::__ANON__() called
> at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter/Forking.pm line 20
>
> Catalyst::Restarter::Forking::_fork_and_start('Catalyst::Restarter::Forking=HASH(0x95d5190)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter.pm line 80
>
> Catalyst::Restarter::run_and_watch('Catalyst::Restarter::Forking=HASH(0x95d5190)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line 178
>
> Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 48
>
> Class::MOP::Method::Wrapped::__ANON__('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 89
>
> Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0x92d0248)') called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/ScriptRunner.pm line 20
> Catalyst::ScriptRunner::run('Catalyst::ScriptRunner',
> 'EasySaver',
> 'Server') called at script/easysaver_server.pl line 8
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo:
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>
>
>
> --
> will trillich
> "It's only by saying 'no' that you can concentrate on the things that
> are really important." -- Steve Jobs
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/



_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


dan at entropy

May 23, 2010, 6:39 AM

Post #5 of 9 (1733 views)
Permalink
Re: DBIC connecting to remote MySQL [In reply to]

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>
> 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] sabayo:~/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"
created
"/home/dan/src/EasySaver/script/../lib/EasySaver/Model/ESDB.pm.new"
exists "/home/dan/src/EasySaver/script/../t/model_ESDB.t"
dan [at] sabayo:~/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.

Dan


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


benvanstaveren at gmail

May 23, 2010, 6:44 AM

Post #6 of 9 (1753 views)
Permalink
Re: DBIC connecting to remote MySQL [In reply to]

> dan [at] sabayo:~/src/EasySaver$ script/easysaver_create.pl model ESDB
> DBIC::Schema EasySaver dbi:mysql:EasySaver:archeopteryx 'username'
> 'password' '{ AutoCommit => 1 }'
>
>
The above won't work because you tell it your schema is 'EasySaver.pm' -
which is your main app file, so it's never created.

Try this and look at lib/EasySaver/Schema.pm

script/easysaver_create.pl model ESDB DBIC::Schema EasySaver::Schema
dbi:mysql:EasySaver:archeopteryx 'user' 'pass' '{ AutoCommit => 1 }'

--
Ben van Staveren
phone: +62 81 70777529
email: benvanstaveren [at] gmail


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


dan at entropy

May 23, 2010, 7:02 AM

Post #7 of 9 (1734 views)
Permalink
Re: DBIC connecting to remote MySQL [In reply to]

Hi Ben. Thanks for the response.

On Sun, 2010-05-23 at 20:44 +0700, Ben van Staveren wrote:

> > dan [at] sabayo:~/src/EasySaver$ script/easysaver_create.pl model ESDB
> > DBIC::Schema EasySaver dbi:mysql:EasySaver:archeopteryx 'username'
> > 'password' '{ AutoCommit => 1 }'
> >
> >
> The above won't work because you tell it your schema is 'EasySaver.pm' -
> which is your main app file, so it's never created.
>
> Try this and look at lib/EasySaver/Schema.pm
>
> script/easysaver_create.pl model ESDB DBIC::Schema EasySaver::Schema
> dbi:mysql:EasySaver:archeopteryx 'user' 'pass' '{ AutoCommit => 1 }'

We're getting closer now. Now I get an error that EasySaver::Schema
isn't found ... and the above didn't create it :(

Tomorrow I'm going to use openssh to forward MySQL traffic from
localhost to the database server, and retry, in the hope that the
Schema.pm file isn't being generated because my connection string is
slightly wrong with respect to defining the server name.

Thanks for your help ( and everyone else who has responded ).

Now I'm going to bed.

Dan


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


benvanstaveren at gmail

May 23, 2010, 7:13 AM

Post #8 of 9 (1733 views)
Permalink
Re: DBIC connecting to remote MySQL [In reply to]

>> script/easysaver_create.pl model ESDB DBIC::Schema EasySaver::Schema
>> dbi:mysql:EasySaver:archeopteryx 'user' 'pass' '{ AutoCommit => 1 }'
>>
>
> We're getting closer now. Now I get an error that EasySaver::Schema
> isn't found ... and the above didn't create it :(
>
>
My bad! Forgot one parameter...

script/easysaver_create.pl model ESDB DBIC::Schema EasySaver::Schema
create=static dbi:mysql:EasySaver:archeopteryx 'user' 'pass'
'{AutoCommit => 1}'

should do the trick :) Funny, you'd imagine the helper script would
loudly complain if you don't tell it create=static but okay...

--
Ben van Staveren
phone: +62 81 70777529
email: benvanstaveren [at] gmail


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


dan at entropy

May 25, 2010, 3:23 AM

Post #9 of 9 (1699 views)
Permalink
Re: DBIC connecting to remote MySQL [In reply to]

On Sun, 2010-05-23 at 21:13 +0700, Ben van Staveren wrote:

> >> script/easysaver_create.pl model ESDB DBIC::Schema EasySaver::Schema
> >> dbi:mysql:EasySaver:archeopteryx 'user' 'pass' '{ AutoCommit => 1 }'
> >>
> >
> > We're getting closer now. Now I get an error that EasySaver::Schema
> > isn't found ... and the above didn't create it :(
> >
> >
> My bad! Forgot one parameter...
>
> script/easysaver_create.pl model ESDB DBIC::Schema EasySaver::Schema
> create=static dbi:mysql:EasySaver:archeopteryx 'user' 'pass'
> '{AutoCommit => 1}'
>
> should do the trick :) Funny, you'd imagine the helper script would
> loudly complain if you don't tell it create=static but okay...

That was it. Thanks :)

Dan


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.