(self, curs, table_name)
Initializes class by loading info about table_name from database.
Initializes class by loading info about table_name from database.
Initializes class by loading info about table_name from database .
def __init__(self, curs, table_name):
        """Initializes class by loading info about table_name from database."""

        BaseStruct.__init__(self, curs, table_name)

        self.table_name = table_name

        # fill args
        schema, name = skytools.fq_name_parts(table_name)
        args = {
            'schema': schema,
            'table': name,
            'fqname': self.fqname,
            'fq2name': skytools.quote_literal(self.fqname),
            'oid': skytools.get_table_oid(curs, table_name),
            'pg_class_oid': skytools.get_table_oid(curs, 'pg_catalog.pg_class'),
        }

        # load table struct
        self.col_list = self._load_elem(curs, self.name, args, TColumn)
        # if db is GP then read also table distribution keys
        if skytools.exists_table(curs, "pg_catalog.gp_distribution_policy"):
            self.dist_key_list = self._load_elem(curs, self.name, args,
                                                 TGPDistKey)
        else:
            self.dist_key_list = None
        self.object_list = [ TTable(table_name, self.col_list,
                                    self.dist_key_list) ]
        self.seq_list = []

        # load seqs
        for col in self.col_list:
            if col.seqname:
                fqname = quote_fqident(col.seqname)
                owner = self.fqname + '.' + quote_ident(col.name)
                seq_args = { 'fqname': fqname, 'owner': skytools.quote_literal(owner) }
                self.seq_list += self._load_elem(curs, col.seqname, seq_args, TSeq)
        self.object_list += self.seq_list

        # load additional objects
        to_load = [TColumnDefault, TConstraint, TIndex, TTrigger,
                   TRule, TGrant, TOwner, TParent]
        for eclass in to_load:
            self.object_list += self._load_elem(curs, self.name, args, eclass)
def __init__ ( self , curs , table_name ) : BaseStruct . __init__ ( self , curs , table_name ) self . table_name = table_name # fill args schema , name = skytools . fq_name_parts ( table_name ) args = { 'schema' : schema , 'table' : name , 'fqname' : self . fqname , 'fq2name' : skytools . quote_literal ( self . fqname ) , 'oid' : skytools . get_table_oid ( curs , table_name ) , 'pg_class_oid' : skytools . get_table_oid ( curs , 'pg_catalog.pg_class' ) , } # load table struct self . col_list = self . _load_elem ( curs , self . name , args , TColumn ) # if db is GP then read also table distribution keys if skytools . exists_table ( curs , "pg_catalog.gp_distribution_policy" ) : self . dist_key_list = self . _load_elem ( curs , self . name , args , TGPDistKey ) else : self . dist_key_list = None self . object_list = [ TTable ( table_name , self . col_list , self . dist_key_list ) ] self . seq_list = [ ] # load seqs for col in self . col_list : if col . seqname : fqname = quote_fqident ( col . seqname ) owner = self . fqname + '.' + quote_ident ( col . name ) seq_args = { 'fqname' : fqname , 'owner' : skytools . quote_literal ( owner ) } self . seq_list += self . _load_elem ( curs , col . seqname , seq_args , TSeq ) self . object_list += self . seq_list # load additional objects to_load = [ TColumnDefault , TConstraint , TIndex , TTrigger , TRule , TGrant , TOwner , TParent ] for eclass in to_load : self . object_list += self . _load_elem ( curs , self . name , args , eclass )