]> rtime.felk.cvut.cz Git - hubacji1/coffee-getter.git/commitdiff
Fix db file in Db constructor
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 21 Mar 2019 06:32:56 +0000 (07:32 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 21 Mar 2019 06:32:56 +0000 (07:32 +0100)
cbdb.py

diff --git a/cbdb.py b/cbdb.py
index a96f3710cf05bd23d57a25b9e9e6878f9de1faa6..1283d51489b0bb28af802d248724d6b3296c68b4 100644 (file)
--- a/cbdb.py
+++ b/cbdb.py
@@ -3,15 +3,19 @@
 from sqlite3 import connect
 from cbconf import Conf
 
+class FileNotSetError(ValueError):
+    pass
+
 class Db:
     def __init__(self, dbpath=False):
         if dbpath:
             self.con = connect(dbpath)
         else:
-            cfg = Conf()
-            self.con = connect(cfg.getCoffeeDbPath())
+            self.con = None
+            raise FileNotSetError("Database file must be set")
         self.cur = self.con.cursor()
         return None
 
     def __del__(self):
-        self.con.close()
+        if self.con:
+            self.con.close()