Re: [cx-oracle-users] ping()
Brought to you by:
atuining
From: <prz...@po...> - 2011-01-17 15:19:46
|
On Mon, Jan 17, 2011 at 01:36:55PM +0000, Paul Moore wrote: > 2011/1/17 <prz...@po...>: > > Hello, > > > > I have been using ping() function to test reachability of some database: > > > > ... > > import cx_Oracle > > import sys > > from time import gmtime, strftime > > > > con = cx_Oracle.connect('user/pass@database') > > try: > > con.ping() > > except cx_Oracle.DatabaseError: > > #print "*** Connection dropped ***" > > STATUS = "DOWN" > > else: > > STATUS= "UP" > > > > con.close() > > print strftime("%Y-%m-%d %H:%M:%S", gmtime()), STATUS > > ... > > > > But it doesn't work - I have checked Oracle logs and it says "UP" even > > when database is down. What is wrong ? > > I would imagine that the connect function (which is not in a try > block) is failing. I'm not sure why your code is not therefore getting > an unhandled exception, but assuming it doesn't, then con is probably > not a valid connection object and con.ping is then failing with > something like an attribute error. I have changed the code to: try: con = cx_Oracle.connect('publikator/gre1czech0@HP_42_OL') con.ping() except cx_Oracle.DatabaseError: #print "*** Connection dropped ***" STATUS = "DOWN" else: STATUS= "UP" Should I avoid "cx_Oracle.DatabaseError" in the "except" clause ? > Or your database is actually up... (what Oracle logs are you looking > at to see that the database is down?) alert log > You might want to check that the database is showing as down if you > connect to it via SQL*Plus. If it is, try the connect() call in the > interactive interpreter and see what it returns. That may help you to > diagnose the problem better. > > Paul. Regards Przemyslaw Bak (przemol) -- http://przemol.blogspot.com/ ---------------------------------------------------------------- Nie pĹaÄ ksiÄgowej! Odbierz prezent. SprawdĹş >> http://linkint.pl/f28f6 |