[FIX] db_exist method works as expected
bzr revid: chs@tinyerp.com-20091201133214-8c6i1ohk5t5u79dz
This commit is contained in:
parent
229c73d741
commit
e345e91365
|
@ -286,11 +286,8 @@ class db(netsvc.Service):
|
|||
return True
|
||||
|
||||
def db_exist(self, db_name):
|
||||
try:
|
||||
db = sql_db.db_connect(db_name)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
## Not True: in fact, check if connection to database is possible. The database may exists
|
||||
return bool(sql_db.db_connect(db_name))
|
||||
|
||||
def list(self):
|
||||
db = sql_db.db_connect('template1')
|
||||
|
|
|
@ -310,6 +310,15 @@ class Connection(object):
|
|||
def serialized_cursor(self):
|
||||
return self.cursor(True)
|
||||
|
||||
def __nonzero__(self):
|
||||
"""Check if connection is possible"""
|
||||
try:
|
||||
cr = self.cursor()
|
||||
cr.close()
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
_dsn = ''
|
||||
for p in ('host', 'port', 'user', 'password'):
|
||||
|
|
Loading…
Reference in New Issue