def get_all_tags(): connection = ht_db_connect() cursor = connection.cursor() query = ''' SELECT ht_text, ht_update_timestamp FROM hashtags''' cursor.execute(query) return cursor.fetchall()
def get_tagged_changes(tag): connection = ht_db_connect() cursor = connection.cursor(oursql.DictCursor) query = ''' SELECT * FROM recentchanges AS rc JOIN hashtag_recentchanges AS htrc ON htrc.htrc_id = rc.htrc_id JOIN hashtags AS ht ON ht.ht_id = htrc.ht_id WHERE ht.ht_text = ?''' params = (tag,) cursor.execute(query, params) return cursor.fetchall()
def get_tagged_changes(tag): connection = ht_db_connect() cursor = connection.cursor(oursql.DictCursor) query = ''' SELECT * FROM recentchanges AS rc JOIN hashtag_recentchanges AS htrc ON htrc.htrc_id = rc.htrc_id JOIN hashtags AS ht ON ht.ht_id = htrc.ht_id WHERE ht.ht_text = ?''' params = (tag, ) cursor.execute(query, params) return cursor.fetchall()
def add_complete_record(self, lang, output=None, run_uuid=None): output = output or '' if len(output) > 1024: output = output[:4096] if not run_uuid: run_uuid = RUN_UUID params = (lang, output, run_uuid) conn = ht_db_connect() try: with conn.cursor() as cursor: cursor.execute('INSERT INTO complete_log' ' (lang, output, run_uuid)' ' VALUES (?, ?, ?)', params) finally: conn.close() return
def add_start_record(self, lang, command=None, run_uuid=None): if not command: command = get_command_str() if len(command) > 1024: command = command[:1024] if not run_uuid: run_uuid = RUN_UUID params = (lang, command, run_uuid) conn = ht_db_connect() try: with conn.cursor() as cursor: cursor.execute('INSERT INTO start_log' ' (lang, command, run_uuid)' ' VALUES (?, ?, ?)', params) finally: conn.close() return
def connect(self): self.wiki_connect = wiki_db_connect(self.lang, db_host='analytics') self.ht_connect = ht_db_connect()
def connect(self): wiki_db_name = self.lang + 'wiki_p' wiki_db_host = self.lang + 'wiki.labsdb' self.wiki_connect = db_connect(wiki_db_name, wiki_db_host) self.ht_connect = ht_db_connect()