import os
import logging
import sqlite3

class Slackn(object):
    def __init__(self, dbpath='/tmp/slackn.db'):
        self.conn = sqlite3.connect(dbpath)
        self.cursor = self.conn.cursor()
        if 'notifications' not in self._tables():
            self._initdb()

    def _initdb(self):
        query = ('''create table notifications
                    (host_alias text,
                     host_state text,
                     host_output text)''')
        self.cursor.execute(query)

    def _tables(self):
        """ Return a list of all table names """
        query = '''select name from sqlite_master where type = 'table''''
        return [ i[0] for i in self.cursor.execute(query).fetchall() ]

@@ -14,30 +14,57 @@
 ort 
-logging%0Aimport sqlite3
+uuid%0Aimport logging%0Afrom redis import StrictRedis
 %0A%0Acl
@@ -73,16 +73,18 @@
 s Slackn
+DB
 (object)
@@ -112,166 +112,194 @@
 lf, 
-dbpath='/tmp/slackn.db'):%0A        self.conn = sqlite3.connect(dbpath)%0A        self.cursor = self.conn.cursor()%0A        if 'notifications' not in self._tables(
+redis_host, redis_port):%0A        self.redis = StrictRedis(host=redis_host, port=int(redis_port),%0A                                 decode_responses=True)%0A%0A    def _add_host(self, **kwargs
 ):%0A 
@@ -309,274 +309,324 @@
     
-    
 self.
-_initdb()%0A%0A    def _initdb(self):%0A        query = ('''create table notifications%0A                    (host_alias text,%0A                     host_state text,%0A                     host_output text)''')%0A        self.cursor.execute(query)%0A%0A    def _tables(self)
+redis.hmset('hosts:' + uuid.uuid4(), kwargs)%0A%0A    def _add_service(self, **kwargs):%0A        self.redis.hmset('services:' + uuid.uuid4(), kwargs)%0A%0A    def _state_color(self, state):%0A        if state == 'CRITICAL':%0A            return 'red'%0A        elif state == 'WARNING':%0A            return 'yellow'%0A        else
 :%0A  
@@ -635,190 +635,106 @@
     
-%22%22%22 R
+    r
 eturn 
-a list of all table names %22%22%22%0A        query = '''select name from sqlite_master where type = 'table''''%0A        return %5B i%5B0%5D for i in self.cursor.execute(query).fetchall() %5D
+'green'%0A        %0A    def _fetchall(self):%0A        return self.redis.lrange('hosts', 0, -1)
 %0A

replace sqlite with redis