PgDB: fix connect() return and improve logging
This commit is contained in:
parent
51dd4f5724
commit
6e778a8691
1 changed files with 9 additions and 4 deletions
|
@ -36,14 +36,19 @@ class PgDB:
|
|||
if self.con == 0:
|
||||
try:
|
||||
con = psycopg2.connect(
|
||||
"dbname='%s' user='%s' host='%s' password='%s'" % (
|
||||
self.db, self.user, self.host, self.pwd
|
||||
)
|
||||
dbname=self.db,
|
||||
user=self.user,
|
||||
host=self.host,
|
||||
password=self.pwd
|
||||
)
|
||||
self.con = con
|
||||
except Exception:
|
||||
log.fatal('An error occured during Postgresql database connection.', exc_info=1)
|
||||
logging.fatal(
|
||||
'An error occured during Postgresql database connection (%s@%s, database=%s).',
|
||||
self.user, self.host, self.db, exc_info=1
|
||||
)
|
||||
sys.exit(1)
|
||||
return True
|
||||
|
||||
def close(self):
|
||||
""" Close connection with PostgreSQL server (if opened) """
|
||||
|
|
Loading…
Reference in a new issue