From 30788c15e76e2d58840c0e4b89116572854586da Mon Sep 17 00:00:00 2001 From: pazz Date: Mon, 23 May 2011 21:47:44 +0100 Subject: rename to "alot" read and laugh, alot: http://hyperboleandahalf.blogspot.com/2010/04/alot-is-better-than-you-at-everything.html --- alot/db.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 alot/db.py (limited to 'alot/db.py') diff --git a/alot/db.py b/alot/db.py new file mode 100644 index 00000000..41aa95d9 --- /dev/null +++ b/alot/db.py @@ -0,0 +1,29 @@ +from notmuch import Database + + +class DBManager(): + def __init__(self, path=None, ro=False): + self.ro = ro + self.path = path + + def count_messages(self, querystring): + q = self.query(querystring) + return q.count_messages() + + def search_threads(self, querystring): + q = self.query(querystring) + return q.search_threads() + + def query(self, querystring): + mode = Database.MODE.READ_ONLY + db = Database(path=self.path, mode=mode) + return db.create_query(querystring) + + def update(self, updatestring): + if self.ro: + self.logger.error('I\'m in RO mode') + else: + self.logger.error('DB updates not implemented yet') + mode = Database.MODE.READ_WRITE + db = Database(path=self.path, mode=mode) + return None # do stuff -- cgit v1.2.3