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