comparison talosnames/api.py @ 2:c98f2a383595

make some tables
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 08 Jul 2012 13:53:06 -0700
parents a10ae1ea8325
children 90e477181404
comparison
equal deleted inserted replaced
1:a10ae1ea8325 2:c98f2a383595
3 3
4 class TalosNames(object): 4 class TalosNames(object):
5 graphserver_sql = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/data.sql' 5 graphserver_sql = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/data.sql'
6 schema = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/schema.sql' 6 schema = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/schema.sql'
7 7
8 tables = ['os_list', 8 tables = {'os_list': '(id, name text)',
9 'branches', 9 'branches': '(id, name text)'
10 'machines', 10 'machines': '(id, os_id int, is_throttling int, cpu_speed text, name text, is_active int, date_added int)',
11 'pagesets', 11 'pagesets': '(id, name text)',
12 'tests'] 12 'tests': '(id, name text, pretty_name text, is_chrome int, is_active int, pageset_id int)'
13 }
13 14
14 def __init__(self): 15 def __init__(self):
15 self.db = sqlite3.connect(':memory:') 16 self.db = sqlite3.connect(':memory:')
16 for table in self.tables: 17 data = urllib2.urlopen(self.graphserver_sql).read()
17 pass
18 schema = urllib2.urlopen(self.schema).read()
19 cursor = self.db.cursor() 18 cursor = self.db.cursor()
20 cursor.executescript(schema) 19 for table, schema in self.tables.items():
20 cursor.execute("""CREATE TABLE %s %s""" % (table, schema))
21 self.db.commit()
22 cursor.close()
21 23