in reply to Looking for a way to use one database connection with multiple CGI scripts
that way it won't have unused connections waiting to time out or anything that could cause bad things to happen
I'm afraid chances are in general that more bad things will happen when you try to use shared DB connections with CGI scripts ;) Anyhow, if you really need to do so (for performance reasons), you might want to look into connect_cached, or Apache::DBI (when using mod_perl). But in this case be particularly careful with forking in combination with persistent DB connections (see InactiveDestroy).
Also note that "normal" CGI scripts start up a new process for every HTTP request, but you'd rather want persistent request handlers that allow to keep a DB connection open — as offered by FastCGI or mod_perl. Otherwise, you'd have to have a separate "connection broker" (a persistently running process) that you connect to from the CGI script (e.g. via a socket) in order to delegate the DB query to a free DB handle from a pool of handles managed by the broker (in the hopes that the communication overhead with the broker is less than the overhead resulting from simply opening a new DB connection every time...)
|
|---|