in reply to Re: Reconnecting to a mysqldb
in thread Reconnecting to a mysqldb
While (in case of stoped db):$sth = $dbh->prepare ($sql); # im doing a mysql restart $sth->execute (); # DBD::mysql magically reconnects keeping the prepar +ed statement and executes
So the way I see it it should be a sane and nice way of doing it:$sth= $dbh->prepare ($sql); # stoping mysql $sth->execute (); # DBD::mysql tries, but no connection, reconnecting +and trying again will lose the $dbh->prepare
Prefarable giving arguments like { reconnect_tries => 10, wait_time => 5 } so the scripts can configure themselves how long they are prepared to wait.$sth= $dbh->prepare ($sql); # stoping mysql $sth->execute (); # entering reconnect mode in MyDBI::st/db: while (!$dbh->ping) { sleep 5; MyDBI->connect_like_mysql_reconnects; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Reconnecting to a mysqldb
by perrin (Chancellor) on Nov 07, 2006 at 16:59 UTC |