def setGoogleValue(self, id, google_value, links=''): sql = 'update GoogleResult_mark set google = %s, url = %s where id = %s limit 1' if links is None: linkstr = '' else: linkstr = '\n'.join(links) try: conn = DB.pool().getConnection() cursor = conn.cursor() cursor.execute(sql, (google_value, linkstr, id,)) except Exception, e: ExceptionHelper.print_exec(e)
def popTitlesFromDB(self): sql = 'select id,titleA,titleB from GoogleResult_mark where google is null and updatetime is null order by id limit 1' try: conn = DB.pool().getConnection() cursor = conn.cursor() cursor.execute(sql) data = cursor.fetchall() if(data and len(data) == 1): (id, title1, title2) = data[0] updateSQL = 'update GoogleResult_mark set updatetime = CURRENT_TIMESTAMP where id = %s' cursor.execute(updateSQL, (id,)) return id, title1, title2 except Exception, e: ExceptionHelper.print_exec(e)