in reply to DBI Connection failed: Can't locate object method "FETCH" via package "DBIx::Connector"
You seem to be mixing up DBIx::Class::Schema and DBIx::Connector. Although they are both mechanisms for talking to databases in an Object-Oriented way, you wouldn't typically use them together like that.
The DBIx::Schema 'connect' method just takes a DBI connect list, whereas you are feeding it a DBIx::Connector object, which is why it is complaining. You just need to change the connect bit to :
my $schema = MyTest::Schema->connect( 'DBI:mysql:my_db:192.XXX.XXX.25', 'XX', 'XX' );
Update: It seems connect will also take a code-ref returning a DBI database handle (I thought that you could only do that in connection, you live and learn). The problem is still that you are giving it a DBIx::Connector object rather than a database handle, which can be fixed thusly:
my $schema = MyTest::Schema->connect( sub { my $dbh = DBIx::Connector->new( @{$args} )->dbh; $dbh->{Active} = 1; return $dbh; }
The setting of 'Active' to 'true' seems to be necessary with PostgreSQL (not sure why), but couldn't test against MySQL, so you may not require this. You may have a particular reason for using DBIx::Connector elsewhere in your code, but I would point out what the documentation says about creating a Connector object just to return a handle:
"..there's probably not much point in that, as you'll generally want to hold on to the DBIx::Connector object. Otherwise you'd just use the DBI, no?"
|
|---|