[Catalyst] Database connections leaking

Kevin Nathan knathan at linux54.com
Wed Dec 26 22:23:54 GMT 2007


On Mon, 24 Dec 2007 18:22:13 +0000
Matt S Trout <dbix-class at trout.me.uk> wrote:

> You might want to see about ripping out the C::M::DBI connection
> management and using a DBIx::Class::Storage::DBI object instead - the
> Model::DBI code originates from a copy of the DBIx::Class code but
> I'm unaware of whether bugfixes and refactorings have been propagated
> to it.
> 

That sounds like just the answer I need, but I've been unable to make
it work. This is my starting point, all Model packages look like this:

-----------------------------------------------------------------
package myapp::Model::SomeTable;
use strict; use warnings;

use base qw/
    myapp::Model::DBI
/;

and related subs for table reading, writing, etc. using the
dbh->prepare and dbh->execute method.
-----------------------------------------------------------------

and then the myapp::Model::DBI looks like this:

-----------------------------------------------------------------
package myapp::Model::DBI;
use warnings; use strict;

use base qw(
    Catalyst::Model::DBI
);

__PACKAGE__->config(
    dsn      => 'dbi:Pg:dbname=myapp',
    user     => 'user',
    password => 'pass',
    options  => {AutoCommit => 1, RaiseError=>1}
);
-----------------------------------------------------------------

I want to be able to just replace the myapp::Model::DBI package so I
don't have to modify all the other files. I tried the following, hoping
I could just pass the connection data to 'connect_info' of
DBIx::Class::Storage::DBI:

-----------------------------------------------------------------
package myapp::Model::DBI;
use warnings; use strict;

use base qw(
    DBIx::Class::Storage::DBI
);

__PACKAGE__->connect_info(
    [
        'dbi:Pg:dbname=myapp',
        'user',
        'pass',
    ]
);
-----------------------------------------------------------------

but of course, that doesn't work. I don't know enough about Catalyst or
DBIx to figure out how to do this -- I've tried various ways and it's
just not working.

Any ideas which direction I need to go for this?


-- 
Kevin Nathan
knathan at linux54.com



More information about the Catalyst mailing list