varanasi has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks:

I have a working catalyst app, "SamPool", to which I am adding some standalone scripts. I would like to move the database connection configuration from sampool.conf, which is where it is in my catalyst app, to SamPool.pm, SamPool::Model::DB, or even SamPool::Schema (which is where it is in the standalone app.)

As I read the catalyst faq, http://wiki.catalystframework.org/wiki/faq.view#Configuration, putting the info in SamPool.pm or SamPool::Model::DB should work, though settings placed in either of those would be overwritten by those in sampool.conf. But I cannot get settings placed in SamPool.pm (won't instantiate) or SamPool::Model::DB (won't connect) to work in catalyst.

Perhaps the fact that sampool.conf exists clobbers the settings in SamPool::Model::DB? Perhaps I have goofed in coding the settings when I moved them (though they work for the standalone scripts)?

sampool.conf excerpt

<Model::DB> schema_class SamPool::Schema <connect_info> dsn dbi:SQLite:__path_to(data,SamPool.db)__ </connect_info> </Model::DB>

This works for standalone app but not for catalyst:

SamPool::Model::DB excerpt

__PACKAGE__->config( schema_class => 'SamPool::Schema', connect_info => { dsn => 'dbi:SQLite:data/SamPool.db', user => '', password => '', } );

Replies are listed 'Best First'.
Re: Placing Catalyst Database Connections Settings Outside .conf File
by Corion (Patriarch) on Sep 06, 2016 at 06:44 UTC

    What errors are you getting?

    The doucmentation mentions Config::General, so maybe the problem isn't Catalyst related at all but more about how to make Config::General do your work?

    Maybe you can reduce the problem to a set of two or three small, self-contained files that reproduce your problem? It is hard for us to replicate your situation as we don't have your setup and Catalyst installation etc.

      Certainly a reasonable request.

      I'll post the detailed errors. Coming up with simple instances that reproduce the problem is tough because, at least for me, Catalyst can be impenetrable.

      Probably what I'll end up doing is creating two config files -- one to be read by Catalyst and one by the scripts, at least until I can figure out a better solution.

        I am a fool.

        When I set out to copy the exact language of the error I was getting with one of the options, I realized I was using the built-in server incorrectly -- if it is not run from the directory containing the catalyst app, it will load the app, report no errors but break when it cannot locate the database because of a path problem.

        Thanks for the advice and forbearance.