base.py 文件源码

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

项目:pyetje 作者: rorlika 项目源码 文件源码
def _get_column_info(self, name, type_, nullable,
                                    default, primary_key):

        match = re.match(r'(\w+)(\(.*?\))?', type_)
        if match:
            coltype = match.group(1)
            args = match.group(2)
        else:
            coltype = "VARCHAR"
            args = ''
        try:
            coltype = self.ischema_names[coltype]
            if args is not None:
                args = re.findall(r'(\d+)', args)
                coltype = coltype(*[int(a) for a in args])
        except KeyError:
            util.warn("Did not recognize type '%s' of column '%s'" %
                      (coltype, name))
            coltype = sqltypes.NullType()

        if default is not None:
            default = unicode(default)

        return {
            'name': name,
            'type': coltype,
            'nullable': nullable,
            'default': default,
            'autoincrement': default is None,
            'primary_key': primary_key
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号