Esempio n. 1
0
    def connect(self):
        """Connects to the NAV database"""
        try:
            conn_str = get_connection_string(script_name='servicemon')
            self.db = psycopg2.connect(conn_str)
            atexit.register(self.close)

            LOGGER.info("Successfully (re)connected to NAVdb")
            # Set transaction isolation level to READ COMMITTED
            self.db.set_isolation_level(1)
        except Exception:
            LOGGER.critical("Couldn't connect to db.", exc_info=True)
            self.db = None
Esempio n. 2
0
    def connect(self):
        try:
            conn_str = get_connection_string(script_name='servicemon')
            self.db = psycopg2.connect(conn_str)
            atexit.register(self.close)

            debug("Successfully (re)connected to NAVdb")
            # Set transaction isolation level to READ COMMITTED
            self.db.set_isolation_level(1)
        except Exception, e:
            debug("Couldn't connect to db.", 2)
            debug(str(e), 2)
            self.db = None