def get_schema(self):
        obj = self.model
        cols = obj.__table__.columns

        fields = {}
        for k in cols.keys():
            fields[k] = {}
            fields[k]['type'] = str(cols[k].type)
            if repr(cols[k].type) == 'JsonBlob()':
                fields[k]['type'] = 'JSON'

            if repr(cols[k].type) == 'JsonEntry()':
                fields[k]['type'] = 'JSON_ENTRY'

            fields[k]['primary_key'] = cols[k].primary_key
            fields[k]['unique'] = cols[k].unique or cols[k].primary_key
            fields[k]['updatable'] = True
            fields[k]['required'] = not cols[k].nullable
            fields[k]['read_only'] = False

            if hasattr(obj, '_non_updatable_fields'):
                if k in obj._non_updatable_fields:
                    fields[k]['updatable'] = False

            if len(cols[k].foreign_keys) > 0:
                fields[k]['fk'] = list(cols[k].foreign_keys)[0].target_fullname

        if hasattr(obj, '_synthesized_fields'):
            for syn in obj._synthesized_fields:
                fields[syn] = {'type': 'TEXT',
                               'unique': False,
                               'required': False,
                               'updatable': False,
                               'read_only': True,
                               'primary_key': False}

        return fields
dataset/ETHPy150Open rcbops/opencenter/opencenter/db/abstraction.py/SqlAlchemyAbstraction.get_schema/original