]> rtime.felk.cvut.cz Git - hubacji1/coffee-getter.git/blob - cbdb.py
1283d51489b0bb28af802d248724d6b3296c68b4
[hubacji1/coffee-getter.git] / cbdb.py
1 # -*- coding: utf-8 -*-
2 """Database access."""
3 from sqlite3 import connect
4 from cbconf import Conf
5
6 class FileNotSetError(ValueError):
7     pass
8
9 class Db:
10     def __init__(self, dbpath=False):
11         if dbpath:
12             self.con = connect(dbpath)
13         else:
14             self.con = None
15             raise FileNotSetError("Database file must be set")
16         self.cur = self.con.cursor()
17         return None
18
19     def __del__(self):
20         if self.con:
21             self.con.close()