From 77355baca0f628f5e95cbf1d8bf3c2475a95150f Mon Sep 17 00:00:00 2001 From: Manel Caro Date: Fri, 29 Mar 2019 14:54:24 +0100 Subject: Modify database connection object and xml parser object --- test-cli/test/helpers/psqldb.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'test-cli/test/helpers/psqldb.py') diff --git a/test-cli/test/helpers/psqldb.py b/test-cli/test/helpers/psqldb.py index 26dd03d..ad40618 100644 --- a/test-cli/test/helpers/psqldb.py +++ b/test-cli/test/helpers/psqldb.py @@ -1,13 +1,14 @@ import psycopg2 + class PgSQLConnection(object): - """aaaaaaa""" + """Database Connection Object""" __conection_object = None __db_config = {'dbname': 'testsrv', 'host': '192.168.2.171', 'password': 'Idkfa2009', 'port': 5432, 'user': 'admin'} - def __init__ (self): + def __init__(self): # self.__conection_object = None # if connect_str is not None: # self.__db_config = connect_str @@ -15,10 +16,10 @@ class PgSQLConnection(object): self.__db_config = {'dbname': 'testsrv', 'host': '192.168.2.171', 'password': 'Idkfa2009', 'port': 5432, 'user': 'admin'} - def db_connect (self, connect_str): + def db_connect(self, connect_str): result = False try: - if connect_str == None: + if connect_str is None: self.__conection_object = psycopg2.connect(**self.__db_config) else: self.__db_config = connect_str; @@ -39,14 +40,12 @@ class PgSQLConnection(object): def commit(self): self.__conection_object.commit() - def db_close(self): if self.__conection_object is not None: self.__conection_object.close() del self.__conection_object self.__conection_object = None - def __del__(self): if self.__conection_object is not None: self.__conection_object.close() -- cgit v1.1