Re: Several databases from the same script

[prev] [thread] [next] [Date index for 2004/06/03]

From: Branislav Zahradnik
Subject: Re: Several databases from the same script
Date: 08:32 on 03 Jun 2004
I'm using Pg and another problem is with schemas.

I try to solve more db connections for same layout with dynamic class 
generation.


package My::Class::DBI;
...

package My::Class::DBI::Employee;
...

package My::Class::DBI::Employee::Address;
...

package main;
$db_one = new DBConnection
   (connection => [$dbdns, $dbusr, $dbpwd, { params }],
    schema => $schema,
    layout => 'My::Class::DBI',
   );

It creates reference eq. HASH(0xFFEEDDCC) and new package
DBConnection_HASH_0xFFEEDDCC::My::Class::DBI, with @ISA sets
to ['DBConnection', 'My::Class::DBI'] and method db_Main
(I'm using Symbol::Table) and after successfull connection, it calls
db_Main->do ('set search_path = ' . $schema), if schema is defiend.

and usage:

$db_one->Employee->create (...);
  ... AUTOLOAD method, create package and method Employee
$db_one->Employee->Address->retrieve_all;
  ... same behaviour

It works nice, but I lost all Class::DBI functionality, where fixed 
package name is used (has_a, has_many, ...)

Maybe more troubles should be found if this is used with more db drivers.


Brano.

Several databases from the same script
Gabor Szabo 23:24 on 02 Jun 2004

Re: Several databases from the same script
Tony Bowden 07:25 on 03 Jun 2004

Re: Several databases from the same script
Branislav Zahradnik 08:32 on 03 Jun 2004

Re: Several databases from the same script
Tony Bowden 09:16 on 03 Jun 2004

Re: Several databases from the same script
Tony Bowden 10:02 on 07 Jun 2004

Re: Several databases from the same script
Branislav Zahradnik 13:26 on 07 Jun 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52