blob: 054fab715e664a0c47d47f3dbfea677f696dd89c [file] [log] [blame]
mblighe9cf9d42007-08-31 08:56:00 +00001import sqlite, re
mblighd5c33db2006-10-08 21:34:16 +00002
3class db:
4 def __init__(self):
5 self.con = sqlite.connect('tko_db')
6 self.cur = self.con.cursor()
7
8
9 def select(self, cmd):
mbligh056d0d32006-10-08 22:31:10 +000010 print 'select ' + cmd
mblighd5c33db2006-10-08 21:34:16 +000011 self.cur.execute('select ' + cmd)
12 return self.cur.fetchall()
13
mbligh056d0d32006-10-08 22:31:10 +000014
15 def insert_job(self, tag, job):
mblighe9cf9d42007-08-31 08:56:00 +000016 # is kernel version in tree?
mbligh056d0d32006-10-08 22:31:10 +000017 command = 'insert into jobs ' + \
mblighe9cf9d42007-08-31 08:56:00 +000018 '(tag, machine) ' + \
19 'values (%s, %s) '
20 print command
21 values = (tag, 'UNKNOWN')
mbligh056d0d32006-10-08 22:31:10 +000022 self.cur.execute(command, values)
mblighe9cf9d42007-08-31 08:56:00 +000023 self.con.commit()
24 # Select it back from the job table and find the uniq key
25
26
27 def insert_test(self, job,
28 def lookup_kernel_version(base, patches):
29 command = 'select kversion from kversions where base = %s'
30
31
32 def insert_kernel_version(base, patches):
33 base = re.sub(r'\+.*', '', printable)
34 command = 'select kversion from kversions where printable = %s'
35 self.cur.execute(command, tag)
36 results = self.cur.fetchall()
37 if results:
38 return results[0]
39 command = 'insert into kversions (printable, base) ' + \
40 'values (%s, %s)'
41 self.cur.execute(command, (printable, base))
42 self.con.commit()
mbligh056d0d32006-10-08 22:31:10 +000043
44
45 def find_job(self, tag):
mbligh529f2f32007-08-30 11:22:50 +000046 command = 'select * from jobs where tag = %s'
mbligh056d0d32006-10-08 22:31:10 +000047 self.cur.execute(command, tag)
48 return self.cur.fetchall()