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?"

In reply to Re: DBI Connection failed: Can't locate object method "FETCH" via package "DBIx::Connector" by Myrddin Wyllt
in thread DBI Connection failed: Can't locate object method "FETCH" via package "DBIx::Connector" by losintikfos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.