[Catalyst] model connect info to come from YAML configuration file
Juan Miguel Paredes
juan.paredes at gmail.com
Tue Dec 5 13:39:05 GMT 2006
On 12/5/06, Juan Miguel Paredes <juan.paredes at gmail.com> wrote:
> On 12/5/06, Hermida, Leandro <Leandro.Hermida at fmi.ch> wrote:
> > 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
> >
> >
> > _______________________________________________
> > List: Catalyst at lists.rawmode.org
> > Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> > Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> > Dev site: http://dev.catalyst.perl.org/
> >
> Hi, All!
>
> Currently, I have something like:
>
> __PACKAGE__->config(
> schema_class => 'MyAppBD',
> connect_info => [
> MyApp->config->{'db'},
> MyApp->config->{'db_user'},
> MyApp->config->{'db_password'},
> {AutoCommit => 1}
> ],
> );
>
> Regards.
>
Sorry, _send_ hitted before time...
And in myapp.yml, something like:
db: dbi:Pg:dbname=mydb;host=myhost
db_user: myuser
db_password: mypass
More information about the Catalyst
mailing list