Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: DB Connections across scripts from a module

by proceng (Scribe)
on Jun 03, 2010 at 14:32 UTC ( [id://842929]=note: print w/replies, xml ) Need Help??


in reply to DB Connections across scripts from a module

Just a guess (since you do not show any code:
When you execute the connect:
$dbh = DBI->connect($data_source, $username, $auth, \%attr);
are you declaring the database handle globally or are you declaring it within the "connect" subroutine? If it is the latter, you will never see a connection in other subroutines.

Also, are you checking to make sure that the connect was successful? See perldoc DBI.

Replies are listed 'Best First'.
Re^2: DB Connections across scripts from a module
by LinuxUser2008 (Acolyte) on Jun 07, 2010 at 03:56 UTC
    Hi proceng,
    I am declaring it globally, so i guess, the var does not go out of context and also, i am able to access the var from other subs..

    As JavaFan had stated, the connection is closed when the first script A's execution is complete.. And for the next script to execute, (as it is executed a bit later) we need to initiate a new connection.. Perl modules get unloaded and loaded back in the memory(for every script execution), i guess..
    If i have said something wrong, please correct me

    Regards,
    Blub:)

      If i have said something wrong

      Most definitely. It's not clear what since I don't know how you invoke each script.

      If the process in which script A executed exited, then the var did go out of scope contrary to what you said.

      If the process in which script A executed did not exit, then no modules got unloaded contrary to what you said.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://842929]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found