コード例 #1
0
ファイル: LawDAO.py プロジェクト: AlfredFu/ContentLinking
	def getById(self,id):
		if id:
			try:
				
				self.cursor_stg.execute("SELECT tax.taxid as id,tax.title,tax_content.content,tax.origin_id,tax.provider_id,tax.isEnglish,tax.date,tax.effect_date FROM tax LEFT JOIN tax_content ON tax.taxid=tax_content.taxid WHERE tax.taxid=%s;" % id)
				row=self.cursor_stg.fetchone()
				if row:
					article=Law()	
					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.proDate=row[6]
					article.effectDate=row[7]
					return article
				else:
					raise Exception("No law with id %s found!" %id)
			except Exception,e:
				self.log.error(e)	
コード例 #2
0
ファイル: LawDAO.py プロジェクト: AlfredFu/ContentLinking
	def getByOrigin(self,originId,providerId,isEnglish):
		"""
		根据originId,providerId,isEnglish获取法规
		"""
		try:
			self.cursor_stg.execute("SELECT tax.taxid as id,tax.title,tax_content.content,tax.origin_id,tax.provider_id,tax.isEnglish,tax.date,tax.effect_date FROM tax LEFT JOIN tax_content ON tax.taxid=tax_content.taxid WHERE tax.origin_id='%s' and tax.provider_id=%s and tax.isEnglish='%s' and display=1;" % (originId,providerId,isEnglish))
			row=self.cursor_stg.fetchone()
			if row:
				article=Law()	
				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.proDate=row[6]
				article.effectDate=row[7]
				return article
			else:
				raise Exception("No law with origin_id:%s,provider_id:%s,isEnglish:%s found!" %(originId,providerId,isEnglish))
		except Exception,e:
			self.log.error(e)