(self, tbl, src_db, dst_db, where)
Actual comparison.
Actual comparison.
Actual comparison .
def do_compare(self, tbl, src_db, dst_db, where):
        """Actual comparison."""

        src_curs = src_db.cursor()
        dst_curs = dst_db.cursor()

        self.log.info('Counting %s' % tbl)

        q = "select count(1) as cnt, sum(hashtext(t.*::text)) as chksum from only _TABLE_ t where %s;" %  where
        q = self.cf.get('compare_sql', q)
        q = q.replace('_TABLE_', skytools.quote_fqident(tbl))

        f = "%(cnt)d rows, checksum=%(chksum)s"
        f = self.cf.get('compare_fmt', f)

        self.log.debug("srcdb: " + q)
        src_curs.execute(q)
        src_row = src_curs.fetchone()
        src_str = f % src_row
        self.log.info("srcdb: %s" % src_str)

        self.log.debug("dstdb: " + q)
        dst_curs.execute(q)
        dst_row = dst_curs.fetchone()
        dst_str = f % dst_row
        self.log.info("dstdb: %s" % dst_str)

        src_db.commit()
        dst_db.commit()

        if src_str != dst_str:
            self.log.warning("%s: Results do not match!" % tbl)
            return False
        else:
            self.log.info("%s: OK!" % tbl)
            return True
def do_compare ( self , tbl , src_db , dst_db , where ) : src_curs = src_db . cursor ( ) dst_curs = dst_db . cursor ( ) self . log . info ( 'Counting %s' % tbl ) q = "select count(1) as cnt, sum(hashtext(t.*::text)) as chksum from only _TABLE_ t where %s;" % where q = self . cf . get ( 'compare_sql' , q ) q = q . replace ( '_TABLE_' , skytools . quote_fqident ( tbl ) ) f = "%(cnt)d rows, checksum=%(chksum)s" f = self . cf . get ( 'compare_fmt' , f ) self . log . debug ( "srcdb: " + q ) src_curs . execute ( q ) src_row = src_curs . fetchone ( ) src_str = f % src_row self . log . info ( "srcdb: %s" % src_str ) self . log . debug ( "dstdb: " + q ) dst_curs . execute ( q ) dst_row = dst_curs . fetchone ( ) dst_str = f % dst_row self . log . info ( "dstdb: %s" % dst_str ) src_db . commit ( ) dst_db . commit ( ) if src_str != dst_str : self . log . warning ( "%s: Results do not match!" % tbl ) return False else : self . log . info ( "%s: OK!" % tbl ) return True