[Catalyst] C::M::DBIC::Schema external configuration
Matt S Trout
dbix-class at trout.me.uk
Thu May 31 15:42:20 GMT 2007
On Thu, May 31, 2007 at 04:09:31PM +0200, Sven Eppler wrote:
> Hello There!
>
> I've got a (hopefully) quite easy question :)
>
> If i wanted to have my database connection information seperated from the
> code in my myApp.yml file for Catalyst::Model::DBIC::Schema, how would i
> actually do that?
>
> Of course i could do:
>
> Model:
> MyDB:
> connect_info:
> - DSN
> - USER
> - PASSWORD
>
> But actually i don't like it this way. Also i will have to add the
> AutoCommit => 1 stuff into the "userconfig" (and obviously i don't want
> such internals to be tweaked by a novice user).
>
> I would prefer to have just three questionable parameters: Databasename,
> username and password? I tried in my myApp.yml file:
>
> databaseconfig:
> username: blah
> password: foo
> databasename: bar
in MyApp.pm
sub finalize_config {
my $app = shift;
$app->next::method(@_);
$app->config('Model::DB' => {
connect_info => [
'dbi:mysql:dbname='.$app->config->{databaseconfig}{databasename},
$app->config->{databaseconfig}{username},
$app->config->{databaseconfig}{password},
{ AutoCommit => 1 }
]
});
}
or similar depending on your DBD etc.
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/
More information about the Catalyst
mailing list