[Catalyst] How to use CDBI model outside Catalyst

Maxim Nechaev nechaev at technodesign.ru
Tue Dec 6 08:41:04 CET 2005


I have a Catalyst Application with CDBI model:

## MyApp/lib/MyApp/Model/CDBI.pm #################
package MyApp::Model::CDBI;
use base 'Catalyst::Model::CDBI';
use strict;
use warnings;

__PACKAGE__->config
(
    'Class-DBI' =>
    {
        dsn           => 'dbi:mysql:test',
        user          => 'root',
        password      => '',
        options       => {},
        relationships => 0,
    },
);

1;
##################################################



Also I have a script outside Catalyst application in which i want use
CDBI model. Now this script look like:

## MyApp/script/myapp_cron.pl ####################
#!/usr/bin/perl -w

use strict;
use FindBin;
use lib "$FindBin::Bin/../lib";

use MyApp::Model::CDBI;
...
##################################################

But it is not enough to start using MyApp::Model::CDBI::* classes.
I think there need some additional initialization. But i can't find
which.
Can anybody help me?
Thanks.


--
Maxim Nechaev




More information about the Catalyst mailing list