[DBIx-Class] Using multiple databases / schemas in DBIC and Catalyst

jagdish eashwar jagdish.eashwar at gmail.com
Sun Jul 20 17:30:46 BST 2008


Hi Matt,

I wanted to use more than one database / schema in a web application using
Catalyst and DBIC.  In this connection, I had asked a question on the
Catalyst mailing list because I was not able to set up relationships between
tables in two separate Mysql schemas. You replied that it was possible if
separate DBIC namespaces were set up, and suggested that for further
discussion, I should ask the question on the DBIx mailing list.

To recap, I am working on two small Catalyst web applications.  One deals
with the leave particulars of the employees  and the other with the hardware
issued to them. Both these applications use some common information about
the employees. At present, I am maintaining these 'common' tables in the
schemas of both the applications. I would like to put the 'common' tables in
a third schema and make the two applications access them from there.

Accordingly, I put the tables in separate schemas and created two separate
models using the Catalyst 'create' helper script. Then I manually put in the
relationships between the tables in the two schemas. However, when I used
these accessors in the tt2 templates, i got the following undef error.

undef error - DBIx::Class::Relationship::Accessor::__ANON__(): Can't find
source for Myhardware::Schema::MyhardwareDB::Hardware at
/home/jag/catalyst_trials/Myhardware/root/src/usr_fragment.tt2 line 8

In the MyApp.pm script, I tried using 'load_namespaces' instead of
'load_classes' , but the Catalyst development server wouldn't start
thereafter. From your reply, I get a feeling that I should perhaps prefix
the schema name to the table name like:

__PACKAGE__table->('db1.tbl1').

But the Catalyst helper scripts warn that nothing above the md5sum line
should be changed.

I am new at what I am doing and shall be glad to receive help.

Jagdish Eashwar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20080720/27c=
d2d2f/attachment.htm


More information about the DBIx-Class mailing list