def getAllVersions(self):
     sql = "SELECT src_origin_id,src_provider_id,src_isenglish,des_origin_id,des_provider_id,des_isenglish FROM versions WHERE src_isenglish='Y' and des_isenglish='Y';"
     try:
         self.cursor_stg.execute(sql)
         for row in self.cursor_stg.fetchall():
             version = Version()
             version.srcOriginId = row[0]
             version.srcProviderId = row[1]
             version.srcIsEnglish = row[2]
             version.desOriginId = row[3]
             version.desProviderId = row[4]
             version.desIsEnglish = row[5]
             yield version
     except Exception, e:
         self.log.error(e)
Exemple #2
0
	def switchTableContent(self,fromTable='versions',toTable='versions_backup'):
		selectsql="SELECT src_origin_id,src_provider_id,src_isenglish,des_origin_id,des_provider_id,des_isenglish FROM "+fromTable+" WHERE src_isenglish='Y' and des_isenglish='Y';"	
		cleansql="delete from %s" % toTable
		try:
			self.cursor_stg.execute(cleansql)
			self.conn_stg.commit()
			self.cursor_stg.execute(selectsql)
			for row in self.cursor_stg.fetchall():
				version=Version()
				version.srcOriginId=row[0]
				version.srcProviderId=row[1]
				version.srcIsEnglish=row[2]
				version.desOriginId=row[3]
				version.desProviderId=row[4]
				version.desIsEnglish=row[5]
				addsql="replace into "+toTable+"(src_origin_id,src_provider_id,src_isenglish,des_origin_id,des_provider_id,des_isenglish) values('%s',%s,'%s','%s',%s,'%s');" % version.toTuple()
			
				self.cursor_stg.execute(addsql)
				self.conn_stg.commit()
		except Exception,e:
			self.log.error(e)