[Catalyst] DBIC connecting to remote MySQL

will at serensoft.com will at serensoft.com
Sun May 23 12:21:21 GMT 2010


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 =3D 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.homelinux.org> 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 =3D> 'EasySaver',
>
>    connect_info =3D> {
>        dsn =3D> 'dbi:mysql:dbname=3DEasySaver;host=3Darcheopteryx',
>        user =3D> 'username',
>        password =3D> 'password',
>        AutoCommit =3D> q{1},
>    }
> );
>
> Doesn't work.
>
> Also tried this:
>
> __PACKAGE__->config(
>    schema_class =3D> 'EasySaver',
>
>    connect_info =3D> {
>        dsn =3D> 'dbi:mysql:EasySaver',
>        host =3D> 'archeopteryx',
>        user =3D> 'EasySaver',
>        password =3D> 'loaderup',
>        AutoCommit =3D> q{1},
>    }
> );
>
> Also doesn't work.
>
> When I try to start the server:
>
> export DBIC_TRACE=3D1
> 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/Attrib=
ute.pm
> line 746
>
> Moose::Meta::Attribute::_coerce_and_verify('Moose::Meta::Attribute=3DHASH=
(0x995cbb0)',
> 'EasySaver', 'EasySaver::Model::ESDB=3DHASH(0x9998ee0)') called at
> /usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/Attrib=
ute.pm
> line 398
>
> Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=
=3DHASH(0x995cbb0)',
> 'Moose::Meta::Instance=3DHASH(0x9a62198)',
> 'EasySaver::Model::ESDB=3DHASH(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=3DHASH(0x992c1=
20)',
> '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=3DHASH(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=3DHASH(0x992c12=
0)',
> '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=3DREF(0x967ee9=
0)')
> 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=3DHASH(0=
x92d0248)')
> 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::Forki=
ng=3DHASH(0x95d5190)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter.pm line 80
>
> Catalyst::Restarter::run_and_watch('Catalyst::Restarter::Forking=3DHASH(0=
x95d5190)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line =
178
>
> Catalyst::Script::Server::run('Catalyst::Script::Server=3DHASH(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=3DHASH(0x=
92d0248)')
> 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=3DHASH(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=3DREF(0x967ee9=
0)')
> 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=3DHASH(0=
x92d0248)')
> 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::Forki=
ng=3DHASH(0x95d5190)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Restarter.pm line 80
>
> Catalyst::Restarter::run_and_watch('Catalyst::Restarter::Forking=3DHASH(0=
x95d5190)')
> called at /usr/lib/perl5/site_perl/5.10.1/Catalyst/Script/Server.pm line =
178
>
> Catalyst::Script::Server::run('Catalyst::Script::Server=3DHASH(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=3DHASH(0x=
92d0248)')
> 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=3DHASH(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.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100523/6b3f9=
9ac/attachment.htm


More information about the Catalyst mailing list