Пример #1
0
    def addCategoricalFromFile(self,filename,unique=False):
        """
        Useful, but still a bit of a hack--should be a special method of adding a group
        that automatically creates the json file.
        """
        file = open(filename)
        firstTwo = file.readline().split("\t")
        name = firstTwo[1].rstrip("\n")
        anchor = firstTwo[0]
        definition = {"field":name,"datatype":"categorical","type":"character","unique":False}

        #Currently the anchortype has to be a MediumInt.
        #That's extremely inefficient.
        anchorType = "MEDIUMINT"

        thisField = dataField(definition,
                              self.db,
                              anchorType,
                              anchor=firstTwo[0],
                              table=definition["field"]+"Disk",
                              fasttab=definition["field"] + "Heap")

        thisField.buildDiskTable(fileLocation=filename)

        thisField.buildLookupTable()

        self.db.query(thisField.updateVariableDescriptionTable())

        query = "SELECT memoryCode FROM masterVariableTable WHERE name='%s'" % (name)
        #print query;
        commands = self.db.query(query).fetchall()[0][0];
        for query in splitMySQLcode(commands):
            self.db.query(query)
Пример #2
0
 def reloadMemoryTables(self, force=False):
     """
     Checks to see if memory tables need to be repopulated (by seeing if they are empty)
     and then does so if necessary.
     """
     existingCreateCodes = self.db.query(
         "SELECT tablename,memoryCode FROM masterTableTable").fetchall()
     for row in existingCreateCodes:
         """
         For each table, it checks to see if the table is currently populated; if not,
         it runs the stored code to repopulate the table. (It checks length because
         memory tables are emptied on a restart).
         """
         tablename = row[0]
         try:
             cursor = self.db.query("SELECT count(*) FROM %s" % (tablename),
                                    silent=True)
             currentLength = cursor.fetchall()[0][0]
             logging.debug("Current Length is %d" % currentLength)
         except:
             currentLength = 0
         if currentLength == 0 or force:
             for query in splitMySQLcode(row[1]):
                 self.db.query("SET optimizer_search_depth=0")
                 self.db.query(query)
Пример #3
0
 def reloadMemoryTables(self):
     existingCreateCodes = self.db.query("SELECT tablename,memoryCode FROM masterTableTable").fetchall();
     for row in existingCreateCodes:
         """
         For each table, it checks to see if the table is currently populated; if not,
         it runs the stored code to repopulate the table. (It checks length because
         memory tables are emptied on a restart).
         """
         tablename = row[0]
         try:
             cursor = self.db.query("SELECT count(*) FROM %s" %(tablename))
             currentLength = cursor.fetchall()[0][0]
         except:
             currentLength = 0
         if currentLength==0:
             for query in splitMySQLcode(row[1]):
                 self.db.query(query)
 def reloadMemoryTables(self,force=False):
     """
     Checks to see if memory tables need to be repopulated (by seeing if they are empty)
     and then does so if necessary.
     """
     existingCreateCodes = self.db.query("SELECT tablename,memoryCode FROM masterTableTable").fetchall();
     for row in existingCreateCodes:
         """
         For each table, it checks to see if the table is currently populated; if not,
         it runs the stored code to repopulate the table. (It checks length because
         memory tables are emptied on a restart).
         """
         tablename = row[0]
         try:
             cursor = self.db.query("SELECT count(*) FROM %s" %(tablename))
             currentLength = cursor.fetchall()[0][0]
             logging.debug("Current Length is %d" %currentLength)
         except:
             currentLength = 0
         if currentLength==0 or force:
             for query in splitMySQLcode(row[1]):
                 self.db.query(query)
Пример #5
0
    def addCategoricalFromFile(self, filename, unique=False):
        """
        Useful, but still a bit of a hack--should be a special method of adding a group
        that automatically creates the json file.
        """
        file = open(filename)
        firstTwo = file.readline().split("\t")
        name = firstTwo[1].rstrip("\n")
        anchor = firstTwo[0]
        definition = {
            "field": name,
            "datatype": "categorical",
            "type": "character",
            "unique": False
        }

        #Currently the anchortype has to be a MediumInt.
        #That's extremely inefficient.
        anchorType = "MEDIUMINT"

        thisField = dataField(definition,
                              self.db,
                              anchorType,
                              anchor=firstTwo[0],
                              table=definition["field"] + "Disk",
                              fasttab=definition["field"] + "Heap")

        thisField.buildDiskTable(fileLocation=filename)

        thisField.buildLookupTable()

        self.db.query(thisField.updateVariableDescriptionTable())

        query = "SELECT memoryCode FROM masterVariableTable WHERE name='%s'" % (
            name)
        #print query;
        commands = self.db.query(query).fetchall()[0][0]
        for query in splitMySQLcode(commands):
            self.db.query(query)