Re: [cx-oracle-users] ping()
Brought to you by:
atuining
From: Paul M. <p.f...@gm...> - 2011-01-17 13:37:04
|
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. Or your database is actually up... (what Oracle logs are you looking at to see that the database is down?) 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. |