(self, src_curs, dst_curs, where)
return tbl_expr
Create COPY expession from common fields.
Create COPY expession from common fields.
Create COPY expession from common fields .
def gen_copy_tbl(self, src_curs, dst_curs, where):
        """Create COPY expession from common fields."""
        self.pkey_list = skytools.get_table_pkeys(src_curs, self.table_name)
        dst_pkey = skytools.get_table_pkeys(dst_curs, self.table_name)
        if dst_pkey != self.pkey_list:
            self.log.error('pkeys do not match')
            sys.exit(1)

        src_cols = skytools.get_table_columns(src_curs, self.table_name)
        dst_cols = skytools.get_table_columns(dst_curs, self.table_name)
        field_list = []
        for f in self.pkey_list:
            field_list.append(f)
        for f in src_cols:
            if f in self.pkey_list:
                continue
            if f in dst_cols:
                field_list.append(f)

        self.common_fields = field_list

        fqlist = [skytools.quote_ident(col) for col in field_list]

        tbl_expr = "select %s from %s" % (",".join(fqlist), self.fq_table_name)
        if where:
            tbl_expr += ' where ' + where
        tbl_expr = "COPY (%s) TO STDOUT" % tbl_expr

        self.log.debug("using copy expr: %s" % tbl_expr)

        return tbl_expr
def gen_copy_tbl ( self , src_curs , dst_curs , where ) : self . pkey_list = skytools . get_table_pkeys ( src_curs , self . table_name ) dst_pkey = skytools . get_table_pkeys ( dst_curs , self . table_name ) if dst_pkey != self . pkey_list : self . log . error ( 'pkeys do not match' ) sys . exit ( 1 ) src_cols = skytools . get_table_columns ( src_curs , self . table_name ) dst_cols = skytools . get_table_columns ( dst_curs , self . table_name ) field_list = [ ] for f in self . pkey_list : field_list . append ( f ) for f in src_cols : if f in self . pkey_list : continue if f in dst_cols : field_list . append ( f ) self . common_fields = field_list fqlist = [ skytools . quote_ident ( col ) for col in field_list ] tbl_expr = "select %s from %s" % ( "," . join ( fqlist ) , self . fq_table_name ) if where : tbl_expr += ' where ' + where tbl_expr = "COPY (%s) TO STDOUT" % tbl_expr self . log . debug ( "using copy expr: %s" % tbl_expr ) return tbl_expr