Example #1
0
    def storeData(self, keyword, discipline):
        c = self.DB.cursor()
        keyword_id = database.getKeywordId(self.DB,keyword)

        if self.re_uuid.match(discipline):
            discipline_bin_id = self.re_dash.sub("",discipline)
            query = "SELECT keyword_count FROM keyword_discipline_count_querylogs WHERE keyword_id = %s AND discipline_id_bin = UNHEX(%s);"
            c.execute(query,(keyword_id,discipline_bin_id))
            row = c.fetchone()

            if row:
                keyword_count = int(row[0])
                keyword_count += 1
                query = "UPDATE keyword_discipline_count_querylogs SET keyword_count=%s WHERE keyword_id = %s AND discipline_id_bin = UNHEX(%s);"
                c.execute(query,(keyword_count,keyword_id,discipline_bin_id))
            else:
                query = "INSERT INTO keyword_discipline_count_querylogs (keyword_id,discipline_id_bin,keyword_count) VALUES (%s,UNHEX(%s),1);"
                c.execute(query,(keyword_id,discipline_bin_id))

        c.close()