in reply to check if DBI is still connected
Any of the above answers will suit you, but I found this solution to be useful for a similar task of mine, as it does most of the work for you:
our @connection = ($dsn, $user, $passwd, \%options); our $dbh = DBI->connect_cached( @connection ); sub do_query { my = shift; $dbh = DBI->connect_cached( @connection ); ## do query ## }
connect_cached() connects if you aren't currently connected. Of course, you can do this yourself by using:
unless ($dbh->ping) { $dbh = DBI->connect(@connection); }
But why?
|
|---|