How to determine the connection status of a Perl DBI database handler (is there an opend connection)? Something like .NET SqlConnection.State == Open. Maybe something like
defined($dbh->do("some nop sql"))
but cannot find sql nop statement to use.
You can set your database descriptor if it is connected by calling
$dbh->ping();
Some DB drivers do not implement ping, but DBD :: mysql does. An alternative is to run an empty type selector select 1for MySQL. I assume MySQL since your question is tagged. Other databases will have slightly different answers.
ping
select 1
.
- {Active}. perldoc DBI :
{Active}
perldoc DBI
DBI-. [...]"" (, ) "Active" , handle . . . , ( "$ dbh- > disconnect" "Active" ).
DBI-. [...]
"" (, ) "Active" , handle . . . , ( "$ dbh- > disconnect" "Active" ).
"" (, )
"Active" , handle . . . , ( "$ dbh- > disconnect" "Active" ).
, , , .
: ping() SELECT 1, . , . , , , , , , ? , , . , -.
ping()
SELECT 1
, ping() SELECT 1 . dbh, - . dbh, , . .
The ping method - although what it does will be dependent on the database driver.
there also $dbh->state()
$dbh->state()
but correct error checking on every call is more reliable.
Source: https://habr.com/ru/post/1758061/More articles:Period on the manual page? - manUsing HtmlTextWriter in ASP.NET MVC - performanceWhere are the links to DirectX assemblies in Visual Studio 2010 - referenceHow to catch all output text in c - chow to remove overlapping lines in postgis - postgresqlSilverlight WebClient Accepts a title that is rewritten in Firefox 3 - http-headersShow blank view in android gallery - androidms close - vbaI "fixed" a memory leak, but ... how best to fix it? - javaC ++ operator = method for const links - c ++All Articles