From fb219d820d5bde2845b1b106104350ca944d5987 Mon Sep 17 00:00:00 2001 From: navid Date: Fri, 23 Nov 2007 12:09:39 +0000 Subject: added missing file git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@460 ef72aa8b-4018-0410-8976-d6e080ef94d8 --- src/extras/sos-html-logs/lib/database.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/extras/sos-html-logs/lib/database.py (limited to 'src') diff --git a/src/extras/sos-html-logs/lib/database.py b/src/extras/sos-html-logs/lib/database.py new file mode 100644 index 00000000..d1082f52 --- /dev/null +++ b/src/extras/sos-html-logs/lib/database.py @@ -0,0 +1,26 @@ +try: from pysqlite2 import dbapi2 as sqlite +except: print "python-sqlite is missing. Exiting."; sys.exit(1) + +from threading import Lock + +class myDB_class: + def __init__(self): + self.dbcon = sqlite.connect(":memory:", check_same_thread=False) + self.dbcon.row_factory = sqlite.Row +# self.dbcur = dbcon.cursor() + self.dblock = Lock() + + self.execute("create table events(eid INTEGER PRIMARY KEY AUTOINCREMENT, date KEY, host, position, parser, message, css_style, tooltip BLOB)") + + def execute(self, query): + self.dblock.acquire() + toret = self.dbcon.execute(query) + self.dblock.release() + return toret + + def execute_and_fetch(self, query): + self.dblock.acquire() + dbcur = self.dbcon.execute(query) + toret = dbcur.fetchall() + self.dblock.release() + return toret -- cgit