6 messages in com.mysql.lists.mysqlCgi perl program and connections/disc...
FromSent OnAttachments
Jack Barnett11 Oct 2000 11:52 
Jack Barnett11 Oct 2000 12:42 
Bill Hess11 Oct 2000 14:20 
Don Read11 Oct 2000 16:47 
Jack Barnett12 Oct 2000 07:21 
Jack Barnett12 Oct 2000 07:22 
Subject:Cgi perl program and connections/disconnects to the mySQL DB?
From:Jack Barnett (jbar@axil.netmate.com)
Date:10/11/2000 11:52:01 AM
List:com.mysql.lists.mysql

Hi,

I am not sure if this is the right place to ask, but I will give it a shot.

I wrote a decent size perl cgi application awhile back with staight ASCII files, for performance and scaliablity reasons I have decided to try using mySQL as a back end to store the data.

The perl cgi program is in 2 parts, one is a "backend" (in-house) module that does the "meat" of the program and the other part is the front end "interface" that makes it glitterly.

What I was trying to do is connect to the DB in the backend module when it is loaded (in the "new" funcation), but the problem is, when it returns it kills the DB connection, I have also tried to connection using a sub routine or method (whatever you real programmers call it :) and when it returns, it kills the connection to the database.

I can connect to the database in the "front end" part of the program, but the only problem with this, is that the module back end won't be able to access any of the data, unless I pass data or do the "heavey" work in the front end, I have considered both this methods, but I think it would really make the program extremely difficult to maintain (come on give me a break, it is already in perl for God's sake! :)

I am not sure the best way to go about this. The only way I can think of is if I fork a child proc off and have that child proc maintain a connection to the DB till the parent dies, but don't know if that is the best solution.

Also "resource wise", would it be better to maintain 1 connection to the db for the life of the program, or to only connectin/disconnect when db access was needed (this might be 10-20 times for the life of the program).

Jack