summaryrefslogtreecommitdiff
path: root/alot/db.py
diff options
context:
space:
mode:
authorpazz <patricktotzke@gmail.com>2011-05-23 21:47:44 +0100
committerpazz <patricktotzke@gmail.com>2011-05-23 21:47:44 +0100
commit30788c15e76e2d58840c0e4b89116572854586da (patch)
treeb8c486b22f89e9f15e6dc3c7652f39428a7c70ba /alot/db.py
parent25a42f2cf157632740e6940b544fca7d5bc98c5f (diff)
rename to "alot"
read and laugh, alot: http://hyperboleandahalf.blogspot.com/2010/04/alot-is-better-than-you-at-everything.html
Diffstat (limited to 'alot/db.py')
-rw-r--r--alot/db.py29
1 files changed, 29 insertions, 0 deletions
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