[Catalyst] Getting DBIC schema from outside Catalyst?

Eden Cardim edencardim at gmail.com
Thu Mar 9 12:14:48 GMT 2017


On Wed, Mar 8, 2017 at 6:15 PM, Robert Brown <rob at intelcompute.com> wrote:

> Hi Jen,
>
> You can use MyApp::Schema outside of Catalyst:
>
> my $schema = MyApp::Schema->connect( $ENV{ LIVE } ? 'live' : 'dev' );
>
> (I'm additionally using DBIx::Class::Schema::Config to be able to connect
> to different servers by using different config files)
>
> $schema->resultset('Instance')->search_rs(), etc.
>
>
If you want to reuse the configuration from MyApp:

use MyApp;
my $schema = MyApp->model('DBICModelName')->schema;

You may need to adjust @INC accordingly, etc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/catalyst/attachments/20170309/7be5b74d/attachment.htm>


More information about the Catalyst mailing list