base.py 文件源码

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

项目:clickhouse-sqlalchemy 作者: xzkostyan 项目源码 文件源码
def get_columns(self, connection, table_name, schema=None, **kw):
        query = 'DESCRIBE TABLE {}'.format(table_name)
        rows = self._execute(connection, query)

        columns = []
        for name, type_, default_type, default_expression in rows:
            # Get only type without extra modifiers.
            type_ = re.search(r'^\w+', type_).group(0)
            try:
                type_ = ischema_names[type_]
            except KeyError:
                type_ = sqltypes.NullType
            columns.append({
                'name': name,
                'type': type_,
                'nullable': True,
                'default': None,
            })
        return columns
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号