changeset 2:c98f2a383595

make some tables
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 08 Jul 2012 13:53:06 -0700
parents a10ae1ea8325
children 90e477181404
files README.txt talosnames/api.py
diffstat 2 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/README.txt	Sun Jul 08 10:09:51 2012 -0700
+++ b/README.txt	Sun Jul 08 13:53:06 2012 -0700
@@ -9,8 +9,8 @@
 * http://hg.mozilla.org/build/talos/file/tip/talos/test.py
 * https://bugzilla.mozilla.org/show_bug.cgi?id=770460
 * http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/file/tip/js/Config.js#l302
+* http://hg.mozilla.org/graphs/raw-file/tip/sql/data.sql
 * http://hg.mozilla.org/graphs/raw-file/tip/sql/schema.sql
-* http://hg.mozilla.org/graphs/raw-file/tip/sql/data.sql
 
 ----
 
--- a/talosnames/api.py	Sun Jul 08 10:09:51 2012 -0700
+++ b/talosnames/api.py	Sun Jul 08 13:53:06 2012 -0700
@@ -5,17 +5,19 @@
     graphserver_sql = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/data.sql'
     schema = 'http://hg.mozilla.org/graphs/raw-file/tip/sql/schema.sql'
 
-    tables = ['os_list',
-              'branches',
-              'machines',
-              'pagesets',
-              'tests']
+    tables = {'os_list': '(id, name text)',
+              'branches': '(id, name text)'
+              'machines': '(id, os_id int, is_throttling int, cpu_speed text, name text, is_active int, date_added int)',
+              'pagesets': '(id, name text)',
+              'tests': '(id, name text, pretty_name text, is_chrome int, is_active int, pageset_id int)'
+              }
 
     def __init__(self):
         self.db = sqlite3.connect(':memory:')
-        for table in self.tables:
-            pass
-        schema = urllib2.urlopen(self.schema).read()
+        data = urllib2.urlopen(self.graphserver_sql).read()
         cursor = self.db.cursor()
-        cursor.executescript(schema)
+        for table, schema in self.tables.items():
+            cursor.execute("""CREATE TABLE %s %s""" % (table, schema))
+        self.db.commit()
+        cursor.close()