예제 #1
0
 def getByOrigin(self, originId, providerId, isEnglish):
     if originId and providerId and isEnglish:
         sql = (
             "select id,title,content,origin_id,provider_id,isEnglish,ex_expert_question_id,update_time from ex_expert_answers where origin_id='%s' and provider_id=%s and isEnglish='%s';"
             % (originId, providerId, isEnglish)
         )
         try:
             self.cursor_stg.execute(sql)
             row = self.cursor_stg.fetchone()
             if row:
                 article = Article()
                 article.id = row[0]
                 article.title = row[1]
                 article.content = row[2]
                 article.originId = row[3]
                 article.providerId = row[4]
                 article.isEnglish = row[5]
                 article.questionId = row[6]
                 article.proDate = row[7]
                 article.contentType = Article.CONTENT_TYPE_MODULEQA
                 return article
             else:
                 raise Exception(
                     "No question answer with origin id:%s,provider id:%s,isEnglish:%s was found"
                     % (originId, providerId, isEnglish)
                 )
         except Exception, e:
             self.log.error(e)
             self.log.error(sql)
예제 #2
0
    def getAll(self):
        sql = """
			select id,title,content,origin_id,provider_id,isEnglish,ex_expert_question_id from ex_expert_answers where isEnglish='Y' and is_display=1
		"""
        try:
            self.cursor_stg.execute(sql)
            for row in self.cursor_stg.fetchall():
                article = Article()
                article.id = row[0]
                article.title = row[1]
                article.content = row[2]
                article.originId = row[3]
                article.providerId = row[4]
                article.isEnglish = row[5]
                article.questionId = row[6]
                article.contentType = Article.CONTENT_TYPE_MODULEQA
                yield article
        except Exception, e:
            self.log.error(e)
            self.log.error(sql)
            self.log.error("Exception occured in getAll() of ModuleQADAO.py")