How to Access Hive via Python?

后端 未结 16 883
小蘑菇
小蘑菇 2020-11-30 17:11

https://cwiki.apache.org/confluence/display/Hive/HiveClient#HiveClient-Python appears to be outdated.

When I add this to /etc/profile:

export PYTHONP         


        
16条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 17:51

    This can be a quick hack to connect hive and python,

    from pyhive import hive
    cursor = hive.connect('YOUR_HOST_NAME').cursor()
    cursor.execute('SELECT * from table_name LIMIT 5',async=True)
    print cursor.fetchall()
    

    Output: List of Tuples

提交回复
热议问题