in reply to Multiple DB Queries using DBI
Yes, you only need to open the connection once.
However if this is some sort of daemon, then maybe you want to create/drop the connection when requests come and go. Remember that connection is a kind of resource. This depends on your planning, how many connections are allowed, and how they should be used.
Also for things like GUI interface, you don't want to keep the connection as long as the GUI is running. Instead you want to create the connection when the user requests some actions by clicking a button etc.
But for a batch job, for sure, open it once, use it, and close it.
|
|---|