[Dbix-class] Passing in the database connection data

Nigel Metheringham nigel.metheringham at dev.intechnology.co.uk
Mon Dec 12 11:54:55 CET 2005


I'd like to get a few suggestions as to the best practice for handling
this...

I have a set of DBIC classes relating to a single database - these all
are based on a parent class which currently has a hard coded DB
connection data:-
        __PACKAGE__->load_components(qw/WebForm PK::Auto::SQLite Core DB/);
        __PACKAGE__->connection(
            'dbi:SQLite:/home/nigel/src/project/db/feature.db',
            '', '',
            {
                RaiseError         => 1,
                PrintError         => 0,
                ShowErrorStatement => 1,
                TraceLevel         => 0,
            }
        );

This set of classes are used by 2 sets of applications - a Catalyst
based app, and a set of data collection scripts which interact with the
database but do not have any Catalyst magic involved.

I'd like to be able to parametrise the database connection info being
used (eg the experimental one on my laptop is likely to stay as a
sqlite, the production and test will be PgSQL).

Any suggestions as to good ways of pushing the connection data into this
would be appreciated - I am considering using a YAML config file for the
Catalyst side, and would be very open to doing that for the other
scripts too.

	Nigel.
-- 
[ Nigel Metheringham           Nigel.Metheringham at InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]





More information about the Dbix-class mailing list