[CDBI] Class::DBI opens database connection for each object?
mortonjt at rochester.rr.com
Fri Apr 11 18:19:03 BST 2008
I have some classes setup as below - there are more classes similar to
Readings that inherit from LoggerDB I've snipped to save space.
My script parses text files from a third party logging system to add
them to the database - I'm trying out Class::DBI to save myself from
having to write alot of basic CRUD SQL. There's thousands of records in
the log files and a reading object is created for each record - what
happens is it dies with the following error after it creates roughly 950
db records. Netstat shows I have about that many tcp connections in
TIME_WAIT, so my guess is I'm hitting a tcp socket limit.
Couldn't connect to localhost:5555/tcp: IO::Socket::INET: connect:
at C:/Perl/site/lib/DBD/PgPP.pm line 124
at C:/Perl/site/lib/Ima/DBI.pm line 328
My question is what am I doing wrong - shouldn't there only be one
database connection open and all db access going through that connection?
I'm running ActivePerl from the Windows XP command line.
use base 'Class::DBI';
use base 'LoggerDB';
Reading->columns(Primary => qw/reading_timestamp reading_name/);
Reading->columns(Others => qw/reading_value/);
More information about the ClassDBI