(self, curs, new_table_name=None)
return sql
Generate creation SQL.
Generate creation SQL.
Generate creation SQL .
def get_create_sql(self, curs, new_table_name=None):
        """Generate creation SQL."""
        # no ONLY here as table with childs (only case that matters)
        # cannot have contraints that childs do not have
        fmt = "ALTER TABLE %s ADD CONSTRAINT %s\n  %s;"
        if new_table_name:
            name = self.name
            if self.contype in ('p', 'u'):
                name = find_new_name(curs, self.name)
            qtbl = quote_fqident(new_table_name)
            qname = quote_ident(name)
        else:
            qtbl = quote_fqident(self.table_name)
            qname = quote_ident(self.name)
        sql = fmt % (qtbl, qname, self.defn)
        if self.is_clustered:
            sql +=' ALTER TABLE ONLY %s\n  CLUSTER ON %s;' % (qtbl, qname)
        return sql
def get_create_sql ( self , curs , new_table_name = None ) : # no ONLY here as table with childs (only case that matters) # cannot have contraints that childs do not have fmt = "ALTER TABLE %s ADD CONSTRAINT %s\n  %s;" if new_table_name : name = self . name if self . contype in ( 'p' , 'u' ) : name = find_new_name ( curs , self . name ) qtbl = quote_fqident ( new_table_name ) qname = quote_ident ( name ) else : qtbl = quote_fqident ( self . table_name ) qname = quote_ident ( self . name ) sql = fmt % ( qtbl , qname , self . defn ) if self . is_clustered : sql += ' ALTER TABLE ONLY %s\n  CLUSTER ON %s;' % ( qtbl , qname ) return sql