convert.py 文件源码

python
阅读 50 收藏 0 点赞 0 评论 0

项目:PYHelper 作者: raminfp 项目源码 文件源码
def _get_field_class_for_data_type(self, data_type):
        field_cls = None
        types = inspect.getmro(type(data_type))
        # First search for a field class from self.SQLA_TYPE_MAPPING
        for col_type in types:
            if col_type in self.SQLA_TYPE_MAPPING:
                field_cls = self.SQLA_TYPE_MAPPING[col_type]
                if callable(field_cls) and not _is_field(field_cls):
                    field_cls = field_cls(self, data_type)
                break
        else:
            # Try to find a field class based on the column's python_type
            try:
                python_type = data_type.python_type
            except NotImplementedError:
                python_type = None

            if python_type in self.type_mapping:
                field_cls = self.type_mapping[python_type]
            else:
                raise ModelConversionError(
                    'Could not find field column of type {0}.'.format(types[0]))
        return field_cls
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号