Phoenix sqlline 无法在终端上显示 table 的所有列

Phoenix sqlline cannot display all columns of table on terminal

使用phoenix sqlline连接hbase。在 SecureCRT 终端上,我只能看到 table 的三列,其中有 10 多列。我想显示 table 的所有列以测试数据是否正常。有什么配置需要设置吗?

0: jdbc:phoenix:10.35.66.72:2181:/hbase> select * from WL.MSGCENTER_PUSHMESSAGE;
+--------------+---------+---------------------------------------------------------------------------------------------------------------------------------------------+
|    PLANID    | BATCHID |                                                                                                                                                 |
+--------------+---------+---------------------------------------------------------------------------------------------------------------------------------------------+
| 520          | 1       | C285995F-AB23-4CF0-A9A4-F29175E9CD36                                                                                                           |
+--------------+---------+---------------------------------------------------------------------------------------------------------------------------------------------+

已选择 1 行(0.805 秒)

sqlline 不够智能,无法调整列宽。使终端更宽,您可能会看到数据。
理想情况下,我建议您 use squirrel-sql or db-visualizer 连接到 Phoenix。它们是查询 Phoenix 的更好工具。

看看这个:http://search-hadoop.com/m/9UY0h2sGBoSz1Mta1

尝试在启动 sqlline 之前设置终端宽度

stty cols 200

您可以将输出格式从水平更改为垂直

!outputformat vertical

建议使用Jupyter连接HBase

我们的团队使用这种方法,我可以在 Juypter 中通过水平滚动轻松查看所有列。

这是我使用的代码片段:

import phoenixdb
from sqlalchemy import create_engine
import pandas as pd

pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
pd.set_option('display.max_colwidth', None)


def hb_query(x):
    conn = phoenixdb.connect(url='http://xxxxx:1234')
    with conn.cursor() as cursor:
        cursor.execute(x)
        data = cursor.fetchall()
        des = cursor.description
    conn.close()
    columns = [i.name.lower() for i in des]
    df_tmp = pd.DataFrame(data, columns=columns)
    
    return df_tmp

df = hb_query("""
SELECT *
FROM TABLE_ABCD
""")

df    #view rows here

仅供参考,您可能需要先设置 Jupyter,我不知道如何设置以及设置是否困难。我领导早就搭建环境了