in reply to storing DBI database handle in CGI::Session object ?

You can't serialize database handles. They are wrappers around C libraries and contain C structures and open sockets. To get persistent database connections, you need to use mod_perl or FastCGI. Plain vanilla CGI can't do it because the perl process is created completely new for every request.
  • Comment on Re: storing DBI database handle in CGI::Session object ?

Replies are listed 'Best First'.
Re^2: storing DBI database handle in CGI::Session object ?
by spx2 (Deacon) on Feb 13, 2008 at 01:01 UTC
    I understand now.
    My only experience with FastCGI was at installing an application
    written using Catalyst to run with fastcgi.
    How do I do this for a single script ? Is there any documentation somewhere
    describing how to run a single script with FastCGI ?
      I'm sure there is, but I don't use FastCGI, so I'm not the best person to ask. I use mod_perl. If you want to learn about mod_perl, there's a lot of documentation at http://perl.apache.org/ and a mailing list that is friendly to newbies. If you want to learn about FastCGI, try looking it up on CPAN or posting a new question here about it.

      To run CGI scripts persistently, you can also use CGI::SpeedyCGI. With this module, a script can be made persistent by changing #!/usr/bin/perl to #!/usr/local/bin/speedy (or what the path to the speedy binary is on your system). Then you can keep database handles in that persistent process.

      -- Kirill