aboutsummaryrefslogtreecommitdiffstats
path: root/src/extras
diff options
context:
space:
mode:
authornavid <navid@ef72aa8b-4018-0410-8976-d6e080ef94d8>2007-11-23 12:09:39 +0000
committernavid <navid@ef72aa8b-4018-0410-8976-d6e080ef94d8>2007-11-23 12:09:39 +0000
commitfb219d820d5bde2845b1b106104350ca944d5987 (patch)
tree21794247d08f048bbe46d46ed2c8289f75bca2e2 /src/extras
parentb5e106bd6af767aaf6e77f90cbe96030c5c0a2af (diff)
downloadsos-fb219d820d5bde2845b1b106104350ca944d5987.tar.gz
added missing file
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@460 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src/extras')
-rw-r--r--src/extras/sos-html-logs/lib/database.py26
1 files changed, 26 insertions, 0 deletions
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