@connected
    def describe(self, table):
        if table not in self.get_metadata().tables:
            print("Table not found: %s" % table)
            return
        tbl = self.get_metadata().tables[table]

        def nullstr(nullable):
            return 'NULL' if nullable else 'NOT NULL'

        def namestr(c):
            return ('*%s' if c.primary_key else '%s') % c.name

        with pager() as out:
            items = ((namestr(c), c.type, nullstr(c.nullable))
                     for c in tbl.columns)
            out.write(b'Columns' + b'\n')
            asciitable.draw(
                FakedResult(sorted(items), 'Name Type Nullable'.split()),
                out, paginate=True,
                max_fieldsize=5000)
            out.write(b'\n')
            out.write(b'Primary Key (*)\n')
            out.write(b'---------------\n')
            pk = ', '.join(c.name for c in tbl.columns if c.primary_key)
            out.write(b'  ')
            if not pk:
                out.write(b'(None Found!)')
            else:
                out.write(pk.encode('utf8'))
            out.write(b'\n\n')
            out.write(b'Foreign Keys\n')
            out.write(b'------------\n')
            fks = self.get_metadata().foreign_keys(table)
            fk = None
            for fk in fks:
                out.write(('  %s\n' % str(fk)).encode('utf8'))
            if fk is None:
                out.write(b'  (None Found)')
            out.write(('\n\nReferences to %s\n' % table).encode('utf8'))
            out.write(b'--------------' + b'-' * len(table) + b'\n')
            fks = self.get_metadata().fields_referencing(table)
            fk = None
            for fk in fks:
                out.write(b'  ' + str(fk).encode('utf8') + b'\n')
            if fk is None:
                out.write(b'  (None found)\n')
            out.write(b'\n\nIndexes\n')

            def items():
                for idx in self.get_metadata().indexes(table):
                    yield (idx.name, ', '.join(c.name for c in idx.columns),
                           idx.unique)
            asciitable.draw(
                FakedResult(sorted(items()), 'Name Columns Unique'.split()),
                out, paginate=True, max_fieldsize=5000)
Print information about a table.
dataset/ETHPy150Open jaysw/ipydb/ipydb/plugin.py/SqlPlugin.describe