[Catalyst] Getting DBIC schema from outside Catalyst?

Robert Brown rob at intelcompute.com
Wed Mar 8 21:15:34 GMT 2017

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.

Hope this helps,


On 08/03/17 21:06, Dr. Jennifer Nussbaum wrote:
> Hi, I hope Im asking this correctly.
> I have a full-blown Catalyst application that connects to many DBIC schemas with information
> stored in the conf file, as per usual C::M::DBIC::Schema practices, and I access them with
> again the usual practices, $c->model('Foo')->search() etc.
> I need to get these schemas from outside the Cat application, e.g. to run cron scripts, etc.
> I was going to write a utility method to parse the config file, connect to the database, etc.,
> but I was wondering that if C::M::DBIC::Schema already does this, is there a way I can access
> this from _outside_ of my Catalyst app, i.e. something I can call to return this from a script?
> Thanks.
> Jen
> _______________________________________________
> 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/

More information about the Catalyst mailing list