view 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
line wrap: on
line source

import sqlite3
import urllib2

class TalosNames(object):
    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': '(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:')
        data = urllib2.urlopen(self.graphserver_sql).read()
        cursor = self.db.cursor()
        for table, schema in self.tables.items():
            cursor.execute("""CREATE TABLE %s %s""" % (table, schema))
        self.db.commit()
        cursor.close()