]> git.ipfire.org Git - oddments/ddns.git/blobdiff - src/ddns/database.py
database: Remove some unused code to close the database
[oddments/ddns.git] / src / ddns / database.py
index 42c343391a9de1b7471291d933b96080c8837cf0..2de050b1b7f590e3c570365b9f0702054a61d0d6 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 ###############################################################################
 #                                                                             #
 # ddns - A dynamic DNS client for IPFire                                      #
@@ -37,9 +37,6 @@ class DDNSDatabase(object):
                # so that we do not do it unnecessarily.
                self._db = None
 
-       def __del__(self):
-               self._close_database()
-
        def _open_database(self, path):
                logger.debug("Opening database %s" % path)
 
@@ -80,11 +77,6 @@ class DDNSDatabase(object):
                # In that case the database file will be created in _open_database().
                return os.access(os.path.dirname(self.path), os.W_OK)
 
-       def _close_database(self):
-               if self._db:
-                       self._db_close()
-                       self._db = None
-
        def _execute(self, query, *parameters):
                if self._db is None:
                        self._db = self._open_database(self.path)
@@ -122,6 +114,9 @@ class DDNSDatabase(object):
                """
                        Returns the timestamp of the last update (with the given status code).
                """
+               if self._db is None:
+                       self._db = self._open_database(self.path)
+
                c = self._db.cursor()
 
                try:
@@ -141,6 +136,9 @@ class DDNSDatabase(object):
                """
                        Returns the update status of the last update.
                """
+               if self._db is None:
+                       self._db = self._open_database(self.path)
+
                c = self._db.cursor()
 
                try:
@@ -156,6 +154,9 @@ class DDNSDatabase(object):
                """
                        Returns the reason string for the last failed update (if any).
                """
+               if self._db is None:
+                       self._db = self._open_database(self.path)
+
                c = self._db.cursor()
 
                try: