[Catalyst] model connect info to come from YAML configuration file

Hermida, Leandro Leandro.Hermida at fmi.ch
Tue Dec 5 13:03:55 GMT 2006


Hello,
 
I remember seeing the question being asked before but I couldn't find it
in the archives.  How does one set up the model connect info to come
from the YAML configuration file?  Using the tutorial as an example, I
created the model file with the helper script myapp_create.pl:
 
$ script/myapp_create.pl model MyAppDB DBIC::Schema MyAppDB
dbi:SQLite:myapp.db '' '' '{ AutoCommit => 1 }'
     exists "/root/dev/MyApp/script/../lib/MyApp/Model"
     exists "/root/dev/MyApp/script/../t"
    created "/root/dev/MyApp/script/../lib/MyApp/Model/MyAppDB.pm"
    created "/root/dev/MyApp/script/../t/model_MyAppDB.t"

Inside MyApp::Model::MyAppDB:

use strict;
use base 'Catalyst::Model::DBIC::Schema';

__PACKAGE__->config(
    schema_class => 'MyAppDB',
    connect_info => [
        'dbi:SQLite:myapp.db',
        '',
        '',
        { AutoCommit => 1 },
        
    ],
);


How would I then make all of the connect info dynamic and acquired from
the myapp.yml file?  In particular the db driver (sqlite, mysql, pg,
oracle), host, port, username, password, etc.


Leandro




More information about the Catalyst mailing list