def cf_db_uniq(self, t1, t2):
        cursor = self.cursor
        col_names = self.get_columns(t1)
        assert utils.list_equal(col_names,self.get_columns(t2)),'Tables have different structure'


        for c,name in enumerate(col_names):
            if name =='index':
                continue
            t_mid = dt.datetime.now()
            # qry = '''
            # select count(*) as cnt from (select {tbl1}.{col} from {tbl1} where not exists (select {tbl2}.{col}  from {tbl2} where {tbl2}.{col}  = {tbl1}.{col} ) 
            # '''
            # result = cursor.execute(qry.format(tbl1=t1,tbl2=t2,col=name))

            qry ='select count(distinct {col}) as cnt from {table}'
            cursor.execute(qry.format(table=t1, col=name))
            result_t1 = cursor.fetchall()
            cursor.execute(qry.format(table=t2, col=name))
            result_t2 = cursor.fetchall()
            # print qry.format(table=t1,col=name)
            # print qry.format(table=t2,col=name)

            print result_t1
            print result_t2
            col_dif = abs(int(result_t1[0][0]) - int(result_t2[0][0]))
            if (col_dif>0):
                message = '{t1} - {r1} <<<<<>>>>> {t2} - {r2}'.format(t1=t1,t2=t2,r1=result_t1[0][0],r2=result_t2[0][0])
            else:        
                message = 'OK'
            print '{} ===== {} - {}'.format(name,message,utils.days_hours_minutes_seconds(dt.datetime.now() - t_mid))
Example #2
0
    def update_local_list(self):
        """
		update method
		list all files in local node
		"""
        mylogger.info('[update_local_list]: update local list')
        temp = self.list_local()
        if not list_equal(temp, self.local_files):
            self.local_files = temp
            self._trigger_update_local()
        return True
Example #3
0
	def update_local_list(self):
		"""
		update method
		list all files in local node
		"""
		mylogger.info('[update_local_list]: update local list')
		temp = self.list_local()
		if not list_equal(temp,self.local_files):
			self.local_files = temp
			self._trigger_update_local()
		return True
Example #4
0
    def update_remote_list(self):
        """
		update method
		list all files in remote nodes
		"""
        mylogger.info('[update_remote_list]: update remote list')
        for other in self.known.copy():
            if other == self.url:
                continue
            else:
                lt = self.list_other(other)
                if other in self.remote_files:
                    if not list_equal(lt, self.remote_files[other]):
                        self.remote_files[other] = lt
                        if not len(lt):
                            del self.remote_files[other]
                        self._trigger_update_remote()
                elif len(lt):  # k not in dict
                    self.remote_files[other] = lt
                    self._trigger_update_remote()
        return True
Example #5
0
	def update_remote_list(self):
		"""
		update method
		list all files in remote nodes
		"""
		mylogger.info('[update_remote_list]: update remote list')
		for other in self.known.copy():
			if other == self.url:
				continue
			else:
				lt = self.list_other(other)
				if other in self.remote_files:
					if not list_equal(lt,self.remote_files[other]):
						self.remote_files[other]= lt
						if not len(lt):
							del self.remote_files[other]
						self._trigger_update_remote()
				elif len(lt):# k not in dict
					self.remote_files[other]= lt
					self._trigger_update_remote()
		return True